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. How can I implement this layout?
Qt 6.11 is out! See what's new in the release blog

How can I implement this layout?

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 3.1k 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.
  • D Offline
    D Offline
    djfm
    wrote on last edited by
    #1

    Hi,

    I want something that seems fairly simple but I can't manage to find how to do it.

    I need to have widgets A and B in a vertical splitter, with the following constraints:

    • A has a variable height but constrained between 30px and 150px
    • B is expanding in all directions without limit
      I want A to have its minimal (30px) size when the application starts. The user is then free to change it using the splitter.

    I have set A's verticalpolicy to Minimum, and B's vertical policy to Expanding.
    I have set A's minimum height to 30 and maximum height to 150px. (If it matters, I'm doing this through the GUI in QtCreator).
    I have not set any size constraints on B.

    What happens is that A always reaches its maximum (150px) size on application startup.

    Here is how it looks like (A is the QTextEdit at the top, B is the QTableView at the bottom):

    !http://i.imgur.com/AatryYx.png(screenshot from the app)!

    The maximum and minimum allowed sizes of A are well enforced, but I can't figure out how to make A start with its minimum height and not the maximum.

    Any idea?

    Thanks in advance!

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      I think geometry values is what defines the size at startup. You might also want to try 'Preferred' as your size policy instead of minimum.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        djfm
        wrote on last edited by
        #3

        Thanks, but the geometry values are grayed out in QtEditor, I cannot change them!

        1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          QSplitter is a little tricky control sometimes. What you can do is:

          • reset al the settings you've changed, sizes, policies etc. (just to avoid anything interfering)
          • set only minimum and maximum height for the top widget (don't change policies, they don't really matter here)
          • set Vertical Stretch of the top widget to 1
          • set Vertical Stretch of the bottom widget to something high(like 100)

          This should work as you wanted.
          EDIT: It might not show in the designer, but it will work when you run the app.

          1 Reply Last reply
          0
          • D Offline
            D Offline
            djfm
            wrote on last edited by
            #5

            Thanks, but it is actually worse:

            !http://i.imgur.com/HQjqR2E.png(app screenshot)!

            1 Reply Last reply
            0
            • Chris KawaC Offline
              Chris KawaC Offline
              Chris Kawa
              Lifetime Qt Champion
              wrote on last edited by
              #6

              You must have set something on a wrong widget. It also looks like a splitter itself is somehow wrongly positioned. Can you show your object tree and describe what you changed on the surrounding widgets?

              By the "top widget" in the previous post I meant textEdit, by the "bottom widget" - tableWidget.
              For reference here's a screenshot with my working example:
              !http://img405.imageshack.us/img405/2364/splitternl.jpg(splitter example)!

              1 Reply Last reply
              0
              • D Offline
                D Offline
                djfm
                wrote on last edited by
                #7

                Ok my bad, I must have set something wrong, I redid it like you said and it is working now. Many thanks!

                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