QFormLayout does not expand widget full height to maximum widget height



  • I have an issue with getting a QTreewidget full height inside a QFormLayout. I'm on Windows 10 and use QT 5.7

    Things I tried:

    • all possible Vertical policy's without success.
    • Change the FieldGrowthPolicy of the layout to AllNonFixedFieldsGrow
    • Use another widget, all fail to make this work

    That's all the options I found to possibly make this work.

    Here's what I try to achieve:
    qtQformLayoutIssue.png

    Here's my ui file:

    <?xml version="1.0" encoding="UTF-8"?>
    <ui version="4.0">
     <class>Dialog</class>
     <widget class="QDialog" name="Dialog">
      <property name="geometry">
       <rect>
        <x>0</x>
        <y>0</y>
        <width>760</width>
        <height>747</height>
       </rect>
      </property>
      <property name="windowTitle">
       <string>Dialog</string>
      </property>
      <layout class="QFormLayout" name="formLayout">
       <item row="0" column="0">
        <widget class="QLabel" name="label">
         <property name="text">
          <string>Please grow the treeview:</string>
         </property>
        </widget>
       </item>
       <item row="0" column="1">
        <widget class="QTreeWidget" name="treeWidget">
         <property name="sizePolicy">
          <sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
           <horstretch>0</horstretch>
           <verstretch>0</verstretch>
          </sizepolicy>
         </property>
         <column>
          <property name="text">
           <string notr="true">1</string>
          </property>
         </column>
        </widget>
       </item>
      </layout>
     </widget>
     <resources/>
     <connections/>
    </ui>
    


  • I think QFormLayout inserts a spacer at the bottom by default. Convert it to a QGridLayout to have the desired result



  • @VRonin Okay, that works better, thanks.
    However, now the labels are center aligned vertically and the only way to change this seems to be in the AddWidget function.
    Is there a way to do this in Qt Designer? Can't seem to select a QGridLayout's cell to set properties of that cell.



  • Just click on the label and set the alignment property


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.