Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QDockWidget & sizepolicy size with scroll area...



  • Hey

    I'm trying to set a size policy of my dockWidget to have stretch of factor 2+. So that I know this widget will always try to force its size to be wider than others... I'm a bit stuck as to which size I have to adjust? It seems that chaning them does not do anything much ?

    I also don't know how to hide central widget in designer...sigh. Still any ideas?

    <?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>668</width>
        <height>599</height>
       </rect>
      </property>
      <property name="windowTitle">
       <string>MainWindow</string>
      </property>
      <widget class="QWidget" name="centralwidget">
       <property name="enabled">
        <bool>false</bool>
       </property>
       <layout class="QGridLayout" name="gridLayout_2">
        <property name="leftMargin">
         <number>0</number>
        </property>
        <property name="topMargin">
         <number>0</number>
        </property>
        <property name="rightMargin">
         <number>0</number>
        </property>
        <property name="bottomMargin">
         <number>0</number>
        </property>
        <item row="0" column="0">
         <widget class="QWidget" name="widget" native="true">
          <property name="maximumSize">
           <size>
            <width>0</width>
            <height>0</height>
           </size>
          </property>
         </widget>
        </item>
       </layout>
      </widget>
      <widget class="QDockWidget" name="dockWidget_3">
       <property name="sizePolicy">
        <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
         <horstretch>0</horstretch>
         <verstretch>0</verstretch>
        </sizepolicy>
       </property>
       <attribute name="dockWidgetArea">
        <number>1</number>
       </attribute>
       <widget class="QWidget" name="dockWidgetContents_3">
        <property name="sizePolicy">
         <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
          <horstretch>0</horstretch>
          <verstretch>0</verstretch>
         </sizepolicy>
        </property>
        <layout class="QGridLayout" name="gridLayout">
         <item row="0" column="0">
          <widget class="QScrollArea" name="scrollArea">
           <property name="sizePolicy">
            <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
             <horstretch>10</horstretch>
             <verstretch>0</verstretch>
            </sizepolicy>
           </property>
           <property name="widgetResizable">
            <bool>true</bool>
           </property>
           <widget class="QWidget" name="scrollAreaWidgetContents">
            <property name="geometry">
             <rect>
              <x>0</x>
              <y>0</y>
              <width>984</width>
              <height>540</height>
             </rect>
            </property>
            <property name="sizePolicy">
             <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
              <horstretch>0</horstretch>
              <verstretch>0</verstretch>
             </sizepolicy>
            </property>
            <layout class="QHBoxLayout" name="horizontalLayout">
             <item>
              <widget class="QPushButton" name="pushButton">
               <property name="text">
                <string>PushButton</string>
               </property>
              </widget>
             </item>
             <item>
              <widget class="QPushButton" name="pushButton_2">
               <property name="text">
                <string>PushButton</string>
               </property>
              </widget>
             </item>
             <item>
              <widget class="QPushButton" name="pushButton_3">
               <property name="text">
                <string>PushButton</string>
               </property>
              </widget>
             </item>
             <item>
              <widget class="QPushButton" name="pushButton_4">
               <property name="text">
                <string>PushButton</string>
               </property>
              </widget>
             </item>
             <item>
              <widget class="QPushButton" name="pushButton_5">
               <property name="text">
                <string>PushButton</string>
               </property>
              </widget>
             </item>
             <item>
              <widget class="QPushButton" name="pushButton_6">
               <property name="text">
                <string>PushButton</string>
               </property>
              </widget>
             </item>
             <item>
              <widget class="QPushButton" name="pushButton_7">
               <property name="text">
                <string>PushButton</string>
               </property>
              </widget>
             </item>
             <item>
              <widget class="QPushButton" name="pushButton_9">
               <property name="text">
                <string>PushButton</string>
               </property>
              </widget>
             </item>
             <item>
              <widget class="QPushButton" name="pushButton_11">
               <property name="text">
                <string>PushButton</string>
               </property>
              </widget>
             </item>
             <item>
              <widget class="QPushButton" name="pushButton_10">
               <property name="text">
                <string>PushButton</string>
               </property>
              </widget>
             </item>
             <item>
              <widget class="QPushButton" name="pushButton_8">
               <property name="text">
                <string>PushButton</string>
               </property>
              </widget>
             </item>
             <item>
              <widget class="QPushButton" name="pushButton_12">
               <property name="text">
                <string>PushButton</string>
               </property>
              </widget>
             </item>
            </layout>
           </widget>
          </widget>
         </item>
        </layout>
       </widget>
      </widget>
      <widget class="QDockWidget" name="dockWidget_4">
       <property name="sizePolicy">
        <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
         <horstretch>0</horstretch>
         <verstretch>0</verstretch>
        </sizepolicy>
       </property>
       <attribute name="dockWidgetArea">
        <number>2</number>
       </attribute>
       <widget class="QWidget" name="dockWidgetContents_4">
        <layout class="QGridLayout" name="gridLayout_3">
         <item row="0" column="0">
          <widget class="QPushButton" name="pushButton_13">
           <property name="text">
            <string>PushButton</string>
           </property>
          </widget>
         </item>
        </layout>
       </widget>
      </widget>
     </widget>
     <resources/>
     <connections/>
    </ui>
    
    
    

Log in to reply