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. QFormLayout does not expand widget full height to maximum widget height
Forum Updated to NodeBB v4.3 + New Features

QFormLayout does not expand widget full height to maximum widget height

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 3.5k Views
  • 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.
  • S Offline
    S Offline
    StormeNet
    wrote on last edited by
    #1

    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>
    
    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

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

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      S 1 Reply Last reply
      3
      • VRoninV VRonin

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

        S Offline
        S Offline
        StormeNet
        wrote on last edited by
        #3

        @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.

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          Just click on the label and set the alignment property

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          1
          • A Offline
            A Offline
            adcpk
            wrote on last edited by
            #5

            You should set the object in the last row of formlayout (see QTreewidget), its vertical expanding factor should not be 0.

            1 Reply Last reply
            0

            • Login

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