Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QToolbox changes width
Forum Updated to NodeBB v4.3 + New Features

QToolbox changes width

Scheduled Pinned Locked Moved Unsolved General and Desktop
layoutqtoolbox
3 Posts 2 Posters 358 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Musmuris
    wrote on 25 Sept 2024, 15:01 last edited by
    #1

    Hi,
    I've got an issue where a toolbox width resizes depending on which page is selected - as can be seen in the following.

    4618b811-948d-46d4-bd0c-5ff534c7fa02-image.png

    The designer code is below, and loading that into Designer and previewing you can see the issue. What I'd like is that the toolbox picks it's widest page's preferred size and uses that as it's own, so changing pages doesn't move it*. I'd rather not have to see min or max sizes as that then breaks if I add or remove stuff and have to go through each one to check.

    <?xml version="1.0" encoding="UTF-8"?>
    <ui version="4.0">
     <class>Form</class>
     <widget class="QWidget" name="Form">
      <property name="geometry">
       <rect>
        <x>0</x>
        <y>0</y>
        <width>462</width>
        <height>519</height>
       </rect>
      </property>
      <property name="windowTitle">
       <string>Form</string>
      </property>
      <layout class="QHBoxLayout" name="horizontalLayout">
       <item>
        <widget class="QGroupBox" name="leftGroup">
         <property name="title">
          <string>GroupBox</string>
         </property>
         <layout class="QVBoxLayout" name="verticalLayout_2">
          <item>
           <layout class="QHBoxLayout" name="horizontalLayout_2">
            <item>
             <widget class="QLabel" name="label">
              <property name="text">
               <string>TextLabel</string>
              </property>
             </widget>
            </item>
            <item>
             <widget class="QLineEdit" name="lineEdit_2"/>
            </item>
           </layout>
          </item>
          <item>
           <widget class="QSlider" name="horizontalSlider">
            <property name="orientation">
             <enum>Qt::Orientation::Horizontal</enum>
            </property>
           </widget>
          </item>
          <item>
           <widget class="QToolBox" name="toolBox">
            <property name="currentIndex">
             <number>1</number>
            </property>
            <widget class="QWidget" name="page">
             <property name="geometry">
              <rect>
               <x>0</x>
               <y>0</y>
               <width>199</width>
               <height>353</height>
              </rect>
             </property>
             <attribute name="label">
              <string>Page 1</string>
             </attribute>
            </widget>
            <widget class="QWidget" name="page_2">
             <property name="geometry">
              <rect>
               <x>0</x>
               <y>0</y>
               <width>302</width>
               <height>347</height>
              </rect>
             </property>
             <attribute name="label">
              <string>Page 2</string>
             </attribute>
             <layout class="QVBoxLayout" name="verticalLayout_3">
              <item>
               <widget class="QLabel" name="label_2">
                <property name="text">
                 <string>This is a long label that I'm putting here to see the size</string>
                </property>
               </widget>
              </item>
              <item>
               <widget class="QLineEdit" name="lineEdit"/>
              </item>
             </layout>
            </widget>
           </widget>
          </item>
         </layout>
        </widget>
       </item>
       <item>
        <widget class="QWidget" name="widgetRight" native="true">
         <layout class="QVBoxLayout" name="verticalLayout">
          <item>
           <widget class="QGroupBox" name="groupBox">
            <property name="title">
             <string>GroupBox</string>
            </property>
            <layout class="QHBoxLayout" name="horizontalLayout_4">
             <item>
              <widget class="QToolBox" name="toolBox_2">
               <property name="currentIndex">
                <number>0</number>
               </property>
               <widget class="QWidget" name="page_3">
                <property name="geometry">
                 <rect>
                  <x>0</x>
                  <y>0</y>
                  <width>78</width>
                  <height>143</height>
                 </rect>
                </property>
                <attribute name="label">
                 <string>Page 1</string>
                </attribute>
               </widget>
               <widget class="QWidget" name="page_4">
                <property name="geometry">
                 <rect>
                  <x>0</x>
                  <y>0</y>
                  <width>78</width>
                  <height>143</height>
                 </rect>
                </property>
                <attribute name="label">
                 <string>Page 2</string>
                </attribute>
               </widget>
              </widget>
             </item>
            </layout>
           </widget>
          </item>
          <item>
           <widget class="QGroupBox" name="groupBox_2">
            <property name="title">
             <string>GroupBox</string>
            </property>
            <layout class="QHBoxLayout" name="horizontalLayout_3">
             <item>
              <widget class="QToolBox" name="toolBox_3">
               <property name="currentIndex">
                <number>0</number>
               </property>
               <widget class="QWidget" name="page_5">
                <property name="geometry">
                 <rect>
                  <x>0</x>
                  <y>0</y>
                  <width>78</width>
                  <height>142</height>
                 </rect>
                </property>
                <attribute name="label">
                 <string>Page 1</string>
                </attribute>
               </widget>
               <widget class="QWidget" name="page_6">
                <property name="geometry">
                 <rect>
                  <x>0</x>
                  <y>0</y>
                  <width>78</width>
                  <height>142</height>
                 </rect>
                </property>
                <attribute name="label">
                 <string>Page 2</string>
                </attribute>
               </widget>
              </widget>
             </item>
            </layout>
           </widget>
          </item>
         </layout>
        </widget>
       </item>
      </layout>
     </widget>
     <resources/>
     <connections/>
    </ui>
    
    
    M 1 Reply Last reply 25 Sept 2024, 16:03
    0
    • M Musmuris
      25 Sept 2024, 15:01

      Hi,
      I've got an issue where a toolbox width resizes depending on which page is selected - as can be seen in the following.

      4618b811-948d-46d4-bd0c-5ff534c7fa02-image.png

      The designer code is below, and loading that into Designer and previewing you can see the issue. What I'd like is that the toolbox picks it's widest page's preferred size and uses that as it's own, so changing pages doesn't move it*. I'd rather not have to see min or max sizes as that then breaks if I add or remove stuff and have to go through each one to check.

      <?xml version="1.0" encoding="UTF-8"?>
      <ui version="4.0">
       <class>Form</class>
       <widget class="QWidget" name="Form">
        <property name="geometry">
         <rect>
          <x>0</x>
          <y>0</y>
          <width>462</width>
          <height>519</height>
         </rect>
        </property>
        <property name="windowTitle">
         <string>Form</string>
        </property>
        <layout class="QHBoxLayout" name="horizontalLayout">
         <item>
          <widget class="QGroupBox" name="leftGroup">
           <property name="title">
            <string>GroupBox</string>
           </property>
           <layout class="QVBoxLayout" name="verticalLayout_2">
            <item>
             <layout class="QHBoxLayout" name="horizontalLayout_2">
              <item>
               <widget class="QLabel" name="label">
                <property name="text">
                 <string>TextLabel</string>
                </property>
               </widget>
              </item>
              <item>
               <widget class="QLineEdit" name="lineEdit_2"/>
              </item>
             </layout>
            </item>
            <item>
             <widget class="QSlider" name="horizontalSlider">
              <property name="orientation">
               <enum>Qt::Orientation::Horizontal</enum>
              </property>
             </widget>
            </item>
            <item>
             <widget class="QToolBox" name="toolBox">
              <property name="currentIndex">
               <number>1</number>
              </property>
              <widget class="QWidget" name="page">
               <property name="geometry">
                <rect>
                 <x>0</x>
                 <y>0</y>
                 <width>199</width>
                 <height>353</height>
                </rect>
               </property>
               <attribute name="label">
                <string>Page 1</string>
               </attribute>
              </widget>
              <widget class="QWidget" name="page_2">
               <property name="geometry">
                <rect>
                 <x>0</x>
                 <y>0</y>
                 <width>302</width>
                 <height>347</height>
                </rect>
               </property>
               <attribute name="label">
                <string>Page 2</string>
               </attribute>
               <layout class="QVBoxLayout" name="verticalLayout_3">
                <item>
                 <widget class="QLabel" name="label_2">
                  <property name="text">
                   <string>This is a long label that I'm putting here to see the size</string>
                  </property>
                 </widget>
                </item>
                <item>
                 <widget class="QLineEdit" name="lineEdit"/>
                </item>
               </layout>
              </widget>
             </widget>
            </item>
           </layout>
          </widget>
         </item>
         <item>
          <widget class="QWidget" name="widgetRight" native="true">
           <layout class="QVBoxLayout" name="verticalLayout">
            <item>
             <widget class="QGroupBox" name="groupBox">
              <property name="title">
               <string>GroupBox</string>
              </property>
              <layout class="QHBoxLayout" name="horizontalLayout_4">
               <item>
                <widget class="QToolBox" name="toolBox_2">
                 <property name="currentIndex">
                  <number>0</number>
                 </property>
                 <widget class="QWidget" name="page_3">
                  <property name="geometry">
                   <rect>
                    <x>0</x>
                    <y>0</y>
                    <width>78</width>
                    <height>143</height>
                   </rect>
                  </property>
                  <attribute name="label">
                   <string>Page 1</string>
                  </attribute>
                 </widget>
                 <widget class="QWidget" name="page_4">
                  <property name="geometry">
                   <rect>
                    <x>0</x>
                    <y>0</y>
                    <width>78</width>
                    <height>143</height>
                   </rect>
                  </property>
                  <attribute name="label">
                   <string>Page 2</string>
                  </attribute>
                 </widget>
                </widget>
               </item>
              </layout>
             </widget>
            </item>
            <item>
             <widget class="QGroupBox" name="groupBox_2">
              <property name="title">
               <string>GroupBox</string>
              </property>
              <layout class="QHBoxLayout" name="horizontalLayout_3">
               <item>
                <widget class="QToolBox" name="toolBox_3">
                 <property name="currentIndex">
                  <number>0</number>
                 </property>
                 <widget class="QWidget" name="page_5">
                  <property name="geometry">
                   <rect>
                    <x>0</x>
                    <y>0</y>
                    <width>78</width>
                    <height>142</height>
                   </rect>
                  </property>
                  <attribute name="label">
                   <string>Page 1</string>
                  </attribute>
                 </widget>
                 <widget class="QWidget" name="page_6">
                  <property name="geometry">
                   <rect>
                    <x>0</x>
                    <y>0</y>
                    <width>78</width>
                    <height>142</height>
                   </rect>
                  </property>
                  <attribute name="label">
                   <string>Page 2</string>
                  </attribute>
                 </widget>
                </widget>
               </item>
              </layout>
             </widget>
            </item>
           </layout>
          </widget>
         </item>
        </layout>
       </widget>
       <resources/>
       <connections/>
      </ui>
      
      
      M Offline
      M Offline
      mpergand
      wrote on 25 Sept 2024, 16:03 last edited by mpergand
      #2

      @Musmuris said in QToolbox changes width:

      <layout class="QHBoxLayout" name="horizontalLayout">

      Try to apply a layout stretch of 3,1 to the first hlayout,
      this way the first toolbox will have 2/3 of the window width and the second one 1/3
      Of course you can set the stetch ratio you want 4/1 or any other.

      M 1 Reply Last reply 1 Oct 2024, 10:52
      0
      • M mpergand
        25 Sept 2024, 16:03

        @Musmuris said in QToolbox changes width:

        <layout class="QHBoxLayout" name="horizontalLayout">

        Try to apply a layout stretch of 3,1 to the first hlayout,
        this way the first toolbox will have 2/3 of the window width and the second one 1/3
        Of course you can set the stetch ratio you want 4/1 or any other.

        M Offline
        M Offline
        Musmuris
        wrote on 1 Oct 2024, 10:52 last edited by
        #3

        @mpergand Thanks - this is what I've done but it's not ideal as there two boxes have different "natural" widths as it were, and forcing a proportional size on them is a bit of a kludge. Better than not - but you'd like to think it it shouldn't be needed.

        1 Reply Last reply
        0

        1/3

        25 Sept 2024, 15:01

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved