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. Unwanted vertical padding with QComboBox in nested layout

Unwanted vertical padding with QComboBox in nested layout

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 3 Posters 3.2k 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.
  • M Offline
    M Offline
    msmithers
    wrote on 6 Jan 2016, 03:41 last edited by
    #1

    Hi,
    I'm using QtCreator 3.6.0 with Qt 5.4 on OsX. In the designer, I have a roughly 9 x 6 cell QGridLayout full of check boxes, combos and lineEdits. If I put a stacked widget or horizontal layout in one of the cells, and put a comboBox inside the stacked widget or horizontal layout, the whole QGridLayout row gets additional vertical padding. (The comboBox alone in the same QGridLayout cell doesn't cause the extra vertical padding.)
    I've tried setting all the stacked widget or horizontal layout margins and spacing to 0, but to no effect.
    Can anyone help?
    Thanks,
    Michael

    1 Reply Last reply
    0
    • V Offline
      V Offline
      ValentinMichelet
      wrote on 6 Jan 2016, 10:14 last edited by
      #2

      Hi,

      You have to consult the Layout section of your widget and set its "LayoutLeftMargin" ... "LayoutVerticalSpacing" properties. By default, these values are 9 for the margins and 6 for the spacing.
      This section is visible at the very end of the properties (right bottom window, in pink). Sometimes you have to click on another widget and click back on your first widget in order to make this Layout section appear.

      Tell me if it's clear enough to locate this Layout section, otherwise I'll provide you with some screen shots.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        msmithers
        wrote on 6 Jan 2016, 19:46 last edited by
        #3

        Thanks for the reply.

        Yep, I already found and adjusted the layout section of both the QGridLayout and any other layouts I placed in QGridLayout cells.

        Here are some more details which should hopefully be reproducible.

        I have the QGridLayout set to layoutHorizontalSpacing = 2 and layoutVerticalSpacing = 2. I have checkboxes in the 1st column, combo boxes in the 2nd and 3rd columns and lineEdits in 4th, 5th and 6th columnns. This works as expected in that the row height/spacing looks correct.

        When I replace one of the line edits with, for example, a QHBoxLayout, the QHBoxLayout already has all margins set to 0 and layoutSpacing set to -1. If I build and run without anything added inside the QHBoxLayout, the QGridLayout row height/spacing stays fine.

        When I then add a QComboBox into the QHBoxLayout, the QGridLayout row height/spacing gets larger just for that row, even though there are other QComboBoxes in other cells in the same QGridLayout row. Changing the QHBoxLayout layoutSpacing from -1 to 0 doesn't do anything.

        In place of the QHBoxLayout, I've also tried QStackedWidget and I get the same problem.

        Thanks,

        1 Reply Last reply
        0
        • M Offline
          M Offline
          msmithers
          wrote on 7 Jan 2016, 18:43 last edited by
          #4

          Can anyone else help with this padding problem?

          Thanks,

          1 Reply Last reply
          0
          • E Offline
            E Offline
            elveatles
            wrote on 8 Jan 2016, 04:46 last edited by
            #5

            Maybe posting before and after pictures will better demonstrate the problem.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              msmithers
              wrote on 12 Jan 2016, 05:22 last edited by msmithers 1 Dec 2016, 05:25
              #6

              Here's the QGridLayout without any nested layouts. It just has some basic controls and nothing in the right column.
              https://dl.dropboxusercontent.com/u/12027933/vspacingproblem_1.gif
              The QGridLayout horizontal and vertical spacings are both set to 0.

              Here's the same QGridLayout now with QStackedWidgets in the right column and where each stack has two pages, one with a line edit and one with a combo.
              https://dl.dropboxusercontent.com/u/12027933/vspacingproblem_2.gif
              Note the increase in vertical spacing. (All the QStackedWidgets have margins and h and v layout spacings set to 0.)

              Here's another pic of the QGridLayout with the QStackedWidgets in the right column, but this time with some combo pages showing. It has the same problem as the 2nd pic above.
              https://dl.dropboxusercontent.com/u/12027933/vspacingproblem_3.gif

              The same problem occurs if the QStackedWidgets are replaced with H or V layouts. Either way, QT adds more spacing which I cant remove.

              1 Reply Last reply
              0
              • V Offline
                V Offline
                ValentinMichelet
                wrote on 12 Jan 2016, 07:40 last edited by
                #7

                Did you try to remove margin in each QStackedWidget page?
                Also, could you provide us with your ui file, so we can play with it?

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  msmithers
                  wrote on 14 Jan 2016, 12:41 last edited by
                  #8

                  Yes. The pics above have all the margins and layout spacings in all the stacked widgets pages set to 0.

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    msmithers
                    wrote on 19 Jan 2016, 01:09 last edited by
                    #9

                    Here's an example ui file and screen grab.
                    https://dl.dropboxusercontent.com/u/12027933/mainwindow.ui
                    https://dl.dropboxusercontent.com/u/12027933/mainwindow_screengrab.gif

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      msmithers
                      wrote on 21 Jan 2016, 08:58 last edited by
                      #10

                      BTW It appears that this is a problem on Mac only. On Windows (using QT Creator w MSVC2013) the layout follows the designer settings and verticalSpacing=0 actually gives NO vertical gap for the cases/examples described above.

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        msmithers
                        wrote on 24 Jan 2016, 09:35 last edited by
                        #11

                        Could someone try the UI file I posted? Thanks.

                        1 Reply Last reply
                        0

                        10/11

                        21 Jan 2016, 08:58

                        • Login

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