代码之家  ›  专栏  ›  技术社区  ›  Flying Thunder

QtDesigner-两个大小不同的相同组合框

  •  0
  • Flying Thunder  · 技术社区  · 7 年前

    我正在编写一个小测试程序(翻译程序),以便进入QtDesigner。

    enter image description here

    如您所见,两个组合框的宽度不同-我没有手动更改任何宽度值,我只更改了对齐和布局。除了文本之外,整个左半部分和右半部分是相同的, 除了

    它似乎与存储在组合框中的项目也没有任何关系,遗憾的是,我无法手动更改项目的大小,因为它们似乎绑定在一个布局中。

    有人能告诉我这是怎么回事吗?这不是一个大问题,但看起来很痛苦。

    <?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>711</width>
        <height>402</height>
       </rect>
      </property>
      <property name="maximumSize">
       <size>
        <width>790</width>
        <height>402</height>
       </size>
      </property>
      <property name="windowTitle">
       <string>MainWindow</string>
      </property>
      <widget class="QWidget" name="centralwidget">
       <property name="minimumSize">
        <size>
         <width>663</width>
         <height>0</height>
        </size>
       </property>
       <property name="maximumSize">
        <size>
         <width>795</width>
         <height>414</height>
        </size>
       </property>
       <layout class="QGridLayout" name="gridLayout_2">
        <item row="0" column="0">
         <layout class="QGridLayout" name="gridLayout">
          <item row="0" column="0">
           <layout class="QVBoxLayout" name="InputLayout">
            <item alignment="Qt::AlignHCenter">
             <widget class="QLabel" name="Label_Input">
              <property name="text">
               <string>Input:</string>
              </property>
             </widget>
            </item>
            <item>
             <widget class="QTextEdit" name="Text_Input">
              <property name="undoRedoEnabled">
               <bool>false</bool>
              </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 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;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
              </property>
             </widget>
            </item>
            <item>
             <widget class="QComboBox" name="Combo_Input">
              <property name="enabled">
               <bool>true</bool>
              </property>
              <item>
               <property name="text">
                <string>Auto</string>
               </property>
              </item>
              <item>
               <property name="text">
                <string>en</string>
               </property>
              </item>
              <item>
               <property name="text">
                <string>de</string>
               </property>
              </item>
             </widget>
            </item>
           </layout>
          </item>
          <item row="0" column="1">
           <layout class="QVBoxLayout" name="ButtonLayout">
            <item>
             <widget class="QPushButton" name="Button_Translate">
              <property name="text">
               <string>=&gt;</string>
              </property>
             </widget>
            </item>
            <item>
             <widget class="QPushButton" name="Button_Swap">
              <property name="text">
               <string>&lt;-&gt;</string>
              </property>
             </widget>
            </item>
           </layout>
          </item>
          <item row="0" column="2">
           <layout class="QVBoxLayout" name="OutputLayout">
            <item alignment="Qt::AlignHCenter">
             <widget class="QLabel" name="Label_Output">
              <property name="text">
               <string>Translated result:</string>
              </property>
             </widget>
            </item>
            <item>
             <widget class="QTextBrowser" name="Text_Output">
              <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;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
              </property>
             </widget>
            </item>
            <item>
             <widget class="QComboBox" name="Combo_Output">
              <item>
               <property name="text">
                <string>en</string>
               </property>
              </item>
              <item>
               <property name="text">
                <string>de</string>
               </property>
              </item>
             </widget>
            </item>
           </layout>
          </item>
         </layout>
        </item>
       </layout>
      </widget>
     </widget>
     <resources/>
     <connections/>
    </ui>
    

    我在试图解决这个问题时遇到的另一个大问题是,在破坏布局并设置最小尺寸后,我无法再更改组合框的对齐方式- 即使在我按住ctrl+z键回到原来的位置之后!

    1 回复  |  直到 7 年前
        1
  •  1
  •   olinox14    7 年前

    您可以通过在 minimumsize 部分 例如,尝试使用最小宽度=30px。

    推荐文章