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. Designer and layouts
Qt 6.11 is out! See what's new in the release blog

Designer and layouts

Scheduled Pinned Locked Moved General and Desktop
12 Posts 3 Posters 5.9k Views 1 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.
  • R Offline
    R Offline
    ryadav
    wrote on last edited by
    #1

    I created a simple dialog using designer and grouped a few label and lineedit widgets to the grid layout and then added a vertical spring and buttonbox and grouped everything to a vboxlayout.

    however when i run the program and resize the dialog, everything remains in a fixed size.

    i want the widgets to expand, i checked their setting and the lineedit is set to horizontal expanding property.

    what did i forget to do?

    Kind Regards,
    Rajinder Yadav

    SafetyNet Test Driven Development
    http://safetynet.devmentor.org

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      Hard to analyze without the .ui file. Can you put it somewhere on a download page, so we can have a look at it.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • R Offline
        R Offline
        ryadav
        wrote on last edited by
        #3

        Here is a simpler dialog using a grid layout, i have the same problem, line edit widgets don't expand on resize of dialog.

        @<?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>298</width>
        <height>118</height>
        </rect>
        </property>
        <property name="windowTitle">
        <string>Dialog</string>
        </property>
        <widget class="QWidget" name="">
        <property name="geometry">
        <rect>
        <x>20</x>
        <y>10</y>
        <width>194</width>
        <height>89</height>
        </rect>
        </property>
        <layout class="QGridLayout" name="gridLayout" columnstretch="0,0">
        <property name="verticalSpacing">
        <number>0</number>
        </property>
        <item row="0" column="0">
        <widget class="QLabel" name="label">
        <property name="text">
        <string>TextLabel</string>
        </property>
        </widget>
        </item>
        <item row="0" column="1">
        <widget class="QLineEdit" name="lineEdit"/>
        </item>
        <item row="1" column="0">
        <widget class="QLabel" name="label_2">
        <property name="text">
        <string>TextLabel</string>
        </property>
        </widget>
        </item>
        <item row="1" column="1">
        <widget class="QLineEdit" name="lineEdit_2"/>
        </item>
        <item row="2" column="0">
        <widget class="QLabel" name="label_3">
        <property name="text">
        <string>TextLabel</string>
        </property>
        </widget>
        </item>
        <item row="2" column="1">
        <widget class="QLineEdit" name="lineEdit_3"/>
        </item>
        </layout>
        </widget>
        </widget>
        <layoutdefault spacing="6" margin="11"/>
        <resources/>
        <connections/>
        </ui>
        @

        Kind Regards,
        Rajinder Yadav

        SafetyNet Test Driven Development
        http://safetynet.devmentor.org

        1 Reply Last reply
        0
        • ZlatomirZ Offline
          ZlatomirZ Offline
          Zlatomir
          wrote on last edited by
          #4

          Try this one:
          @<?xml version="1.0" encoding="UTF-8"?>
          <ui version="4.0">
          <class>Dialog</class>
          <widget class="QDialog" name="Dialog">
          <property name="geometry">
          <rect>
          <x>578</x>
          <y>354</y>
          <width>253</width>
          <height>101</height>
          </rect>
          </property>
          <property name="windowTitle">
          <string>Dialog</string>
          </property>
          <layout class="QGridLayout" name="gridLayout">
          <item row="0" column="0">
          <widget class="QLabel" name="label">
          <property name="text">
          <string>TextLabel</string>
          </property>
          </widget>
          </item>
          <item row="0" column="1">
          <widget class="QLineEdit" name="lineEdit"/>
          </item>
          <item row="1" column="0">
          <widget class="QLabel" name="label_2">
          <property name="text">
          <string>TextLabel</string>
          </property>
          </widget>
          </item>
          <item row="1" column="1">
          <widget class="QLineEdit" name="lineEdit_2"/>
          </item>
          <item row="2" column="0">
          <widget class="QLabel" name="label_3">
          <property name="text">
          <string>TextLabel</string>
          </property>
          </widget>
          </item>
          <item row="2" column="1">
          <widget class="QLineEdit" name="lineEdit_3"/>
          </item>
          </layout>
          </widget>
          <layoutdefault spacing="6" margin="11"/>
          <resources/>
          <connections/>
          </ui>@
          I fixed this way:

          1. break your grid layout
          2. select the "background form" and click on grid layout

          https://forum.qt.io/category/41/romanian

          1 Reply Last reply
          0
          • R Offline
            R Offline
            ryadav
            wrote on last edited by
            #5

            Thanks that worked, not intuitive!

            Kind Regards,
            Rajinder Yadav

            SafetyNet Test Driven Development
            http://safetynet.devmentor.org

            1 Reply Last reply
            0
            • ? This user is from outside of this forum
              ? This user is from outside of this forum
              Guest
              wrote on last edited by
              #6

              [quote author="ryadav" date="1297143061"]... not intuitive![/quote]

              ryadav, after designing a few forms you'll find the designer amazing to work with. We use it quite a lot in our team and its very easy.

              1 Reply Last reply
              0
              • ZlatomirZ Offline
                ZlatomirZ Offline
                Zlatomir
                wrote on last edited by
                #7

                2 ryadav, you got to think that the main_layout got to be "owned" by the window, and this main_layout will "contain" the other layouts and widgets.

                See "this documentation page":http://doc.qt.nokia.com/4.7/designer-layouts.html, my main_layout it's actually called Top Level Layout ;)

                https://forum.qt.io/category/41/romanian

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  ryadav
                  wrote on last edited by
                  #8

                  Zlatomir, what if i had other widgets, and i didn't want them to be a part of the grid layout? selecting the form background would select all the widgets inside the form, not what i would want.

                  how would one use the designer in this case to get the same results? that is:

                  select a few items and apply a layout to them
                  select other items including last layout and apply a layout to them and expect stretching and expansion to work

                  the way i tired it originally would seem to be the way to do things, i would just expect the layout to have expansion properties i could set

                  Kind Regards,
                  Rajinder Yadav

                  SafetyNet Test Driven Development
                  http://safetynet.devmentor.org

                  1 Reply Last reply
                  0
                  • ? This user is from outside of this forum
                    ? This user is from outside of this forum
                    Guest
                    wrote on last edited by
                    #9

                    one container can have one layout, so add different containers and set corresponding layouts. nest them as you like ...

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      ryadav
                      wrote on last edited by
                      #10

                      i am actually starting to understand how to use the layouts. from code a layout can contain other layout, so this should be possible via the designer without adding unnecessary widget (containers)

                      Kind Regards,
                      Rajinder Yadav

                      SafetyNet Test Driven Development
                      http://safetynet.devmentor.org

                      1 Reply Last reply
                      0
                      • ZlatomirZ Offline
                        ZlatomirZ Offline
                        Zlatomir
                        wrote on last edited by
                        #11

                        You can do that too

                        You select the Widgets for Grid... (like you did the first time) and then add other Widgets... and select a Layout for the form.
                        You need that (main layout) to achieve the behavior you said in the first post ;) for the rest feel free to nest them as long as you like.

                        example, i used a vertical layout ;)
                        @<?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>298</width>
                        <height>118</height>
                        </rect>
                        </property>
                        <property name="windowTitle">
                        <string>Dialog</string>
                        </property>
                        <widget class="QWidget" name="">
                        <property name="geometry">
                        <rect>
                        <x>20</x>
                        <y>10</y>
                        <width>194</width>
                        <height>89</height>
                        </rect>
                        </property>
                        <layout class="QGridLayout" name="gridLayout" columnstretch="0,0">
                        <property name="verticalSpacing">
                        <number>0</number>
                        </property>
                        <item row="0" column="0">
                        <widget class="QLabel" name="label">
                        <property name="text">
                        <string>TextLabel</string>
                        </property>
                        </widget>
                        </item>
                        <item row="0" column="1">
                        <widget class="QLineEdit" name="lineEdit"/>
                        </item>
                        <item row="1" column="0">
                        <widget class="QLabel" name="label_2">
                        <property name="text">
                        <string>TextLabel</string>
                        </property>
                        </widget>
                        </item>
                        <item row="1" column="1">
                        <widget class="QLineEdit" name="lineEdit_2"/>
                        </item>
                        <item row="2" column="0">
                        <widget class="QLabel" name="label_3">
                        <property name="text">
                        <string>TextLabel</string>
                        </property>
                        </widget>
                        </item>
                        <item row="2" column="1">
                        <widget class="QLineEdit" name="lineEdit_3"/>
                        </item>
                        </layout>
                        </widget>
                        </widget>
                        <layoutdefault spacing="6" margin="11"/>
                        <resources/>
                        <connections/>
                        </ui>@

                        https://forum.qt.io/category/41/romanian

                        1 Reply Last reply
                        0
                        • R Offline
                          R Offline
                          ryadav
                          wrote on last edited by
                          #12

                          Thanks Zlatomir,

                          I was playing around with designer, and I am getting the hang of how the layouts work.

                          Kind Regards,
                          Rajinder Yadav

                          SafetyNet Test Driven Development
                          http://safetynet.devmentor.org

                          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