RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题 / 1327725
Accepted
Никита Пфейфер
Никита Пфейфер
Asked:2022-09-12 18:46:32 +0000 UTC2022-09-12 18:46:32 +0000 UTC 2022-09-12 18:46:32 +0000 UTC

如何正确使用布局管理器?

  • 772

当您尝试安装布局管理器时,整个图像会更改其位置,这是合乎逻辑的。

但我不明白如何安装Spacer's,如何更改它们,以使我的程序看起来与布局管理器之前完全一样。

例如,在这里,左边是我的菜单,它是椭圆形的,只是变平了,我不知道如何返回它的大小。
能不能展示一下。

在此处输入图像描述

你能告诉我如何使我的窗口动态化,但仍将对象留在原处以及如何将图片保留在Frame窗口内,同时保持窗口扩展。

我附上.ui文件:

在此处输入图像描述

Apex.ui

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>1209</width>
    <height>747</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <property name="styleSheet">
   <string notr="true"/>
  </property>
  <property name="animated">
   <bool>true</bool>
  </property>
  <widget class="QWidget" name="centralwidget">
   <property name="styleSheet">
    <string notr="true">background-color: rgb(34, 31, 46);</string>
   </property>
   <widget class="QFrame" name="frame">
    <property name="geometry">
     <rect>
      <x>40</x>
      <y>110</y>
      <width>41</width>
      <height>581</height>
     </rect>
    </property>
    <property name="styleSheet">
     <string notr="true">background-color: rgb(46, 43, 63);
border: 5px solid rgba(255, 255, 255, 0);
border-radius: 20px;

</string>
    </property>
    <property name="frameShape">
     <enum>QFrame::StyledPanel</enum>
    </property>
    <property name="frameShadow">
     <enum>QFrame::Raised</enum>
    </property>
    <widget class="QLabel" name="label_10">
     <property name="geometry">
      <rect>
       <x>-24</x>
       <y>530</y>
       <width>71</width>
       <height>41</height>
      </rect>
     </property>
     <property name="styleSheet">
      <string notr="true">background-color: rgb(34, 31, 46);</string>
     </property>
     <property name="text">
      <string/>
     </property>
     <property name="pixmap">
      <pixmap>../Nikita_Pfeyfer4.png</pixmap>
     </property>
    </widget>
    <widget class="QPushButton" name="menu">
     <property name="geometry">
      <rect>
       <x>5</x>
       <y>4</y>
       <width>31</width>
       <height>31</height>
      </rect>
     </property>
     <property name="styleSheet">
      <string notr="true">background-image: url(:/menu/Изображения/3030.png);
border: 1px solid #a112fe;
border-radius: 10;
</string>
     </property>
     <property name="text">
      <string/>
     </property>
    </widget>
    <widget class="QPushButton" name="spravka">
     <property name="geometry">
      <rect>
       <x>30</x>
       <y>530</y>
       <width>141</width>
       <height>41</height>
      </rect>
     </property>
     <property name="sizePolicy">
      <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
       <horstretch>0</horstretch>
       <verstretch>0</verstretch>
      </sizepolicy>
     </property>
     <property name="font">
      <font>
       <family>Copperplate Gothic Bold</family>
       <pointsize>12</pointsize>
       <weight>50</weight>
       <bold>false</bold>
      </font>
     </property>
     <property name="styleSheet">
      <string notr="true">QPushButton {
    ;
    
    color: rgb(78, 75, 94);
    background-color: rgba(255, 255, 255, 0);
    padding: 5px;

    }
QPushButton:hover {
   
    
    color: rgb(168, 168, 168);
    }

QPushButton:pressed {
    border-style: inset;
   
    color: rgb(214, 214, 214);
    }</string>
     </property>
     <property name="inputMethodHints">
      <set>Qt::ImhNone</set>
     </property>
     <property name="text">
      <string>Reference</string>
     </property>
     <property name="autoExclusive">
      <bool>false</bool>
     </property>
    </widget>
    <widget class="QLabel" name="label_9">
     <property name="geometry">
      <rect>
       <x>-30</x>
       <y>80</y>
       <width>81</width>
       <height>31</height>
      </rect>
     </property>
     <property name="styleSheet">
      <string notr="true">background-color: rgb(34, 31, 46);
border: 2px solid rgba(34, 31, 46, 0); ;

border-radius: 10</string>
     </property>
     <property name="text">
      <string/>
     </property>
     <property name="pixmap">
      <pixmap>../Nikita_Pfeyfer2.png</pixmap>
     </property>
    </widget>
    <widget class="QPushButton" name="weapon">
     <property name="geometry">
      <rect>
       <x>50</x>
       <y>70</y>
       <width>121</width>
       <height>41</height>
      </rect>
     </property>
     <property name="sizePolicy">
      <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
       <horstretch>0</horstretch>
       <verstretch>0</verstretch>
      </sizepolicy>
     </property>
     <property name="font">
      <font>
       <family>Copperplate Gothic Bold</family>
       <pointsize>14</pointsize>
       <weight>50</weight>
       <bold>false</bold>
      </font>
     </property>
     <property name="styleSheet">
      <string notr="true">QPushButton {
    ;
    color: rgb(78, 75, 94);      
    background-color: rgba(255, 255, 255, 0);
    padding: 5px;
    }

QPushButton:hover {
   
    
    
    color: rgb(168, 168, 168);
    }

QPushButton:pressed {
    border-style: inset;
   
    
    color: rgb(214, 214, 214);
    }</string>
     </property>
     <property name="inputMethodHints">
      <set>Qt::ImhNone</set>
     </property>
     <property name="text">
      <string>Weapons</string>
     </property>
     <property name="autoExclusive">
      <bool>false</bool>
     </property>
    </widget>
   </widget>
   <widget class="QFrame" name="frame_2">
    <property name="geometry">
     <rect>
      <x>0</x>
      <y>0</y>
      <width>1211</width>
      <height>21</height>
     </rect>
    </property>
    <property name="styleSheet">
     <string notr="true">background-color: rgb(46, 43, 63);</string>
    </property>
    <property name="frameShape">
     <enum>QFrame::StyledPanel</enum>
    </property>
    <property name="frameShadow">
     <enum>QFrame::Raised</enum>
    </property>
   </widget>
   <widget class="QLabel" name="label">
    <property name="geometry">
     <rect>
      <x>590</x>
      <y>90</y>
      <width>231</width>
      <height>41</height>
     </rect>
    </property>
    <property name="font">
     <font>
      <family>Copperplate Gothic Bold</family>
      <pointsize>28</pointsize>
     </font>
    </property>
    <property name="styleSheet">
     <string notr="true">color: rgb(253, 253, 253);</string>
    </property>
    <property name="text">
     <string>Main Menu</string>
    </property>
    <property name="alignment">
     <set>Qt::AlignCenter</set>
    </property>
   </widget>
   <widget class="Line" name="line">
    <property name="geometry">
     <rect>
      <x>600</x>
      <y>130</y>
      <width>241</width>
      <height>2</height>
     </rect>
    </property>
    <property name="orientation">
     <enum>Qt::Horizontal</enum>
    </property>
   </widget>
   <widget class="QFrame" name="frame_3">
    <property name="geometry">
     <rect>
      <x>260</x>
      <y>180</y>
      <width>261</width>
      <height>161</height>
     </rect>
    </property>
    <property name="styleSheet">
     <string notr="true">background-color: rgb(46, 43, 63);
border: 2px solid #2e2b3f;
border-radius: 10</string>
    </property>
    <property name="frameShape">
     <enum>QFrame::StyledPanel</enum>
    </property>
    <property name="frameShadow">
     <enum>QFrame::Raised</enum>
    </property>
    <widget class="QLabel" name="label_3">
     <property name="geometry">
      <rect>
       <x>70</x>
       <y>0</y>
       <width>121</width>
       <height>41</height>
      </rect>
     </property>
     <property name="font">
      <font>
       <family>Bahnschrift SemiBold</family>
       <pointsize>22</pointsize>
       <weight>75</weight>
       <bold>true</bold>
      </font>
     </property>
     <property name="styleSheet">
      <string notr="true">color: rgb(194, 194, 194);</string>
     </property>
     <property name="text">
      <string>Версия</string>
     </property>
     <property name="alignment">
      <set>Qt::AlignCenter</set>
     </property>
    </widget>
    <widget class="QLabel" name="label_4">
     <property name="geometry">
      <rect>
       <x>70</x>
       <y>60</y>
       <width>121</width>
       <height>61</height>
      </rect>
     </property>
     <property name="font">
      <font>
       <family>Bahnschrift SemiBold</family>
       <pointsize>22</pointsize>
       <weight>75</weight>
       <bold>true</bold>
      </font>
     </property>
     <property name="styleSheet">
      <string notr="true"/>
     </property>
     <property name="text">
      <string>1.0 BETA</string>
     </property>
     <property name="alignment">
      <set>Qt::AlignCenter</set>
     </property>
    </widget>
   </widget>
   <widget class="QTextBrowser" name="textBrowser">
    <property name="geometry">
     <rect>
      <x>570</x>
      <y>170</y>
      <width>256</width>
      <height>351</height>
     </rect>
    </property>
    <property name="styleSheet">
     <string notr="true">background-color: rgb(46, 43, 63);
border: 2px solid #2e2b3f;
border-radius: 10</string>
    </property>
    <property name="html">
     <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:12pt; font-weight:600; color:#c2c2c2;&quot;&gt;ApexHelper&lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt; font-weight:600;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:12pt;&quot;&gt;Эта программа предназначена для того, чтобы помочь новичкам или опытным игрокам более лучше освоить игру&lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:12pt; font-weight:600; color:#c2c2c2;&quot;&gt;_Apex Legends_&lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt; font-weight:600; color:#c2c2c2;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:12pt;&quot;&gt;Тут ты найдёшь подробное описание каждого оружия,&lt;/span&gt;&lt;span style=&quot; font-size:12pt; text-decoration: underline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot; font-size:12pt;&quot;&gt;обвеса и прочих вещей.&lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:12pt; font-style:italic; color:#c2c2c2;&quot;&gt;С уважением, Разработчик &lt;/span&gt;&lt;span style=&quot; font-size:12pt; font-weight:600; font-style:italic; color:#c2c2c2;&quot;&gt;ApexHelper&lt;/span&gt;&lt;span style=&quot; font-size:12pt; color:#c2c2c2;&quot;&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
    </property>
   </widget>
   <widget class="QFrame" name="frame_4">
    <property name="geometry">
     <rect>
      <x>560</x>
      <y>720</y>
      <width>201</width>
      <height>20</height>
     </rect>
    </property>
    <property name="styleSheet">
     <string notr="true">background-color: rgb(46, 43, 63);
border: 2px solid #2e2b3f;
border-radius: 10</string>
    </property>
    <property name="frameShape">
     <enum>QFrame::StyledPanel</enum>
    </property>
    <property name="frameShadow">
     <enum>QFrame::Raised</enum>
    </property>
    <widget class="QLabel" name="label_5">
     <property name="geometry">
      <rect>
       <x>50</x>
       <y>-2</y>
       <width>101</width>
       <height>21</height>
      </rect>
     </property>
     <property name="font">
      <font>
       <family>Bahnschrift SemiBold SemiConden</family>
       <pointsize>12</pointsize>
       <weight>75</weight>
       <bold>true</bold>
      </font>
     </property>
     <property name="text">
      <string>Всё для вас!</string>
     </property>
     <property name="alignment">
      <set>Qt::AlignCenter</set>
     </property>
    </widget>
   </widget>
   <widget class="QTextBrowser" name="textBrowser_2">
    <property name="geometry">
     <rect>
      <x>260</x>
      <y>360</y>
      <width>261</width>
      <height>161</height>
     </rect>
    </property>
    <property name="styleSheet">
     <string notr="true">background-color: rgb(46, 43, 63);
border: 2px solid #2e2b3f;
border-radius: 10</string>
    </property>
    <property name="html">
     <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:16pt; font-weight:600; color:#c2c2c2;&quot;&gt;Информация&lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt; font-weight:600;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:12pt;&quot;&gt;Программа находится в разработке, поэтому, пока что присудствует не вся информация &lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
    </property>
   </widget>
   <widget class="Line" name="line_2">
    <property name="geometry">
     <rect>
      <x>309</x>
      <y>391</y>
      <width>161</width>
      <height>2</height>
     </rect>
    </property>
    <property name="orientation">
     <enum>Qt::Horizontal</enum>
    </property>
   </widget>
   <widget class="Line" name="line_3">
    <property name="geometry">
     <rect>
      <x>331</x>
      <y>219</y>
      <width>121</width>
      <height>2</height>
     </rect>
    </property>
    <property name="orientation">
     <enum>Qt::Horizontal</enum>
    </property>
   </widget>
   <widget class="QTextBrowser" name="textBrowser_3">
    <property name="geometry">
     <rect>
      <x>870</x>
      <y>170</y>
      <width>256</width>
      <height>351</height>
     </rect>
    </property>
    <property name="styleSheet">
     <string notr="true">background-color: rgb(46, 43, 63);
border: 2px solid #6c6c00;
border-radius: 10</string>
    </property>
    <property name="html">
     <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:16pt; color:#c2c2c2;&quot;&gt;Кому принадлежит&lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;Все данные, изображения и прочее из программы, принадлежат компании&lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:14pt; font-weight:600; color:#6f6f0a;&quot;&gt;Respawn Entertainment&lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:14pt; font-weight:600;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:14pt;&quot;&gt;Никому более.&lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:14pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:14pt;&quot;&gt;Их материал был повзаимствован для помощи игрокам.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
    </property>
   </widget>
   <widget class="Line" name="line_4">
    <property name="geometry">
     <rect>
      <x>897</x>
      <y>200</y>
      <width>201</width>
      <height>2</height>
     </rect>
    </property>
    <property name="orientation">
     <enum>Qt::Horizontal</enum>
    </property>
   </widget>
   <widget class="QPushButton" name="mainmenu">
    <property name="geometry">
     <rect>
      <x>50</x>
      <y>20</y>
      <width>81</width>
      <height>81</height>
     </rect>
    </property>
    <property name="styleSheet">
     <string notr="true">background-image: url(:/Fone/Изображения/_Logotip_Proz5.png);
border: 1px solid rgba(255, 255, 255, 0);
</string>
    </property>
    <property name="text">
     <string/>
    </property>
   </widget>
   <zorder>label</zorder>
   <zorder>frame_2</zorder>
   <zorder>frame</zorder>
   <zorder>line</zorder>
   <zorder>frame_3</zorder>
   <zorder>textBrowser</zorder>
   <zorder>frame_4</zorder>
   <zorder>textBrowser_2</zorder>
   <zorder>line_2</zorder>
   <zorder>line_3</zorder>
   <zorder>textBrowser_3</zorder>
   <zorder>line_4</zorder>
   <zorder>mainmenu</zorder>
  </widget>
  <action name="action">
   <property name="text">
    <string>справка</string>
   </property>
  </action>
 </widget>
 <resources>
  <include location="../our/ApexFone.qrc"/>
  <include location="../our/menu.qrc"/>
 </resources>
 <connections/>
</ui>
python
  • 1 1 个回答
  • 10 Views

1 个回答

  • Voted
  1. Best Answer
    S. Nick
    2022-04-12T03:28:02Z2022-04-12T03:28:02Z

    像这样试试

    from PyQt5 import QtCore, QtGui, QtWidgets
    from PyQt5.Qt import *
    
    
    class ImageLabel(QtWidgets.QGraphicsView):
        def __init__(self, *args, **kwargs):
            super(ImageLabel, self).__init__(*args, **kwargs)
            self.setScene(QtWidgets.QGraphicsScene())
            self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) 
            self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
    
        def setImage(self, filename):
            self.setPixmap(QtGui.QPixmap(filename))
    
        def setPixmap(self, pixmap):
            item = QtWidgets.QGraphicsPixmapItem(pixmap)
            item.setTransformationMode(QtCore.Qt.SmoothTransformation)
            self.scene().addItem(item)
    
        def resizeEvent(self, event):
            r = self.scene().itemsBoundingRect()
            self.fitInView(r, QtCore.Qt.KeepAspectRatio)
            super(ImageLabel, self).resizeEvent(event)
            
    
    class Ui_Form(object):
        def setupUi(self, Form):
            Form.setObjectName("Form")
            Form.resize(640, 480)
            self.horizontalLayout = QtWidgets.QHBoxLayout(Form)
            self.horizontalLayout.setObjectName("horizontalLayout")
            self.horizontalLayout.setSpacing(0)
            self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
                    
            self.frameLeft = QtWidgets.QFrame(Form)     
            self.frameLeft.setObjectName("frameLeft")
            self.frameLeft.setStyleSheet(
                "#frameLeft {background-color: #753422;}")
            self.horizontalLayout.addWidget(self.frameLeft, 1)
    
            self.frame = QtWidgets.QFrame(Form)
            self.frame.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
            self.frame.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
            self.frame.setObjectName("frame")
            self.frame.setMaximumHeight(0)
            
            self.verticalLayout = QtWidgets.QVBoxLayout(self.frameLeft)
            self.verticalLayout.setContentsMargins(0, 0, 0, 0)
            self.verticalLayout.setObjectName("verticalLayout")
    
            self.image = ImageLabel()
            self.image.setObjectName("image")
            self.image.setStyleSheet("background-color: #753422;")
            self.verticalLayout.addWidget(self.image)
            
            self.pushButton_2 = QtWidgets.QPushButton(self.frame)
            self.pushButton_2.setObjectName("pushButton_2")
            self.verticalLayout.addWidget(self.pushButton_2)
            
            self.pushButton_3 = QtWidgets.QPushButton(self.frame)
            self.pushButton_3.setObjectName("pushButton_3")
            self.pushButton_3.setIcon(QtGui.QIcon('Ok.png'))
            self.pushButton_3.setIconSize(QtCore.QSize(75, 75))
            self.pushButton_3.setMinimumWidth(175)
            font = QtGui.QFont()
            font.setFamily("Bahnschrift SemiBold SemiConden")
            font.setPointSize(12)
            font.setBold(True)
            font.setWeight(75)
            self.pushButton_3.setFont(font)
            self.verticalLayout.addWidget(self.pushButton_3)        
     
            spacerItem = QtWidgets.QSpacerItem(
                20, 40, 
                QtWidgets.QSizePolicy.Policy.Minimum, 
                QtWidgets.QSizePolicy.Policy.Expanding
            )
            self.verticalLayout.addItem(spacerItem)     
    
            self.pushButton_4 = QtWidgets.QToolButton(self.frame)  
            self.pushButton_4.setObjectName("pushButton_4")
            self.pushButton_4.setFixedSize(75, 75)
            self.pushButton_4.setStyleSheet('''
                #pushButton_4 {
                    border: none;
                    margin: 0px;
                    padding: 0px;
                    border-image: url(Ok.png);        
                }
            ''')         
            self.verticalLayout.addWidget(
                self.pushButton_4, alignment=QtCore.Qt.AlignCenter)        
    
            self.frameRight = QtWidgets.QFrame(Form)         
            self.frameRight.setObjectName("frameRight")
            self.frameRight.setStyleSheet("background-color: #D79771;")
            self.horizontalLayout.addWidget(self.frameRight, 1)
            self.frame_2 = QtWidgets.QFrame(Form)
            self.frame_2.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
            self.frame_2.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
            self.frame_2.setObjectName("frame_2")
            self.frame_2.setMaximumHeight(0)
            
            self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.frameRight)
            self.verticalLayout_2.setObjectName("verticalLayout_2")        
            self.image_2 = ImageLabel()
            self.image_2.setObjectName("image_2")
            self.verticalLayout_2.addWidget(self.image_2)        
            
            self.retranslateUi(Form)
            QtCore.QMetaObject.connectSlotsByName(Form)
    
        def retranslateUi(self, Form):
            _translate = QtCore.QCoreApplication.translate
            Form.setWindowTitle(_translate("Form", "Form"))
            self.pushButton_2.setText(_translate("Form", "Нажми меня"))
            self.pushButton_3.setText(_translate("Form", "Hello World"))
            
    
    class DemoImageLabel(QWidget, Ui_Form):
        def __init__(self):
            super().__init__()
            self.setupUi(self)
            
            self.pushButton_3.setText("Hello World")
    
            self.frameLeft.setMaximumWidth(75)      
    
            self.image.setImage("cat_png.png")        # установите свое изображение !!!
            self.image.setMaximumHeight(200)
            
            self.image_2.setImage("heart.png")        # установите свое изображение !!!
            
            self.pushButton_2.clicked.connect(self.animate_frame_left)
    
            self.animation1 = self.build_animation(self.frameLeft)
           
        def build_animation(self, frameLeft):
            animation = QPropertyAnimation(frameLeft, b"maximumWidth")
            animation.setDuration(800)
            animation.setEasingCurve(QEasingCurve.Type.Linear)
            return animation
    
        def start_animation(self, animation):
            width = animation.targetObject().width()
            animation.stop()
            animation.setStartValue(width)
            animation.setEndValue(75 if width != 75 else 200) 
            animation.start()
    
        def animate_frame_left(self):
            self.start_animation(self.animation1)
            
    
    if __name__ == "__main__":
        import sys
    
        app = QApplication(sys.argv)
        app.setStyle('fusion')
        w = DemoImageLabel()
        w.resize(800, 600)
        w.show()
        sys.exit(app.exec_())
    

    在此处输入图像描述

    在此处输入图像描述

    • 2

相关问题

  • 是否可以以某种方式自定义 QTabWidget?

  • telebot.anihelper.ApiException 错误

  • Python。检查一个数字是否是 3 的幂。输出 无

  • 解析多个响应

  • 交换两个数组的元素,以便它们的新内容也反转

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    表格填充不起作用

    • 2 个回答
  • Marko Smith

    提示 50/50,有两个,其中一个是正确的

    • 1 个回答
  • Marko Smith

    在 PyQt5 中停止进程

    • 1 个回答
  • Marko Smith

    我的脚本不工作

    • 1 个回答
  • Marko Smith

    在文本文件中写入和读取列表

    • 2 个回答
  • Marko Smith

    如何像屏幕截图中那样并排排列这些块?

    • 1 个回答
  • Marko Smith

    确定文本文件中每一行的字符数

    • 2 个回答
  • Marko Smith

    将接口对象传递给 JAVA 构造函数

    • 1 个回答
  • Marko Smith

    正确更新数据库中的数据

    • 1 个回答
  • Marko Smith

    Python解析不是css

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5