Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    How can I implement this layout?

    General and Desktop
    3
    7
    1813
    Loading More Posts
    • 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
      djfm last edited by

      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 Reply Quote 0
      • W
        WizzZZ last edited by

        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.

        There is only 10 types of people in the world: those who understand binary and those who don't.

        1 Reply Last reply Reply Quote 0
        • D
          djfm last edited by

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

          1 Reply Last reply Reply Quote 0
          • Chris Kawa
            Chris Kawa Moderators last edited by

            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 Reply Quote 0
            • D
              djfm last edited by

              Thanks, but it is actually worse:

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

              1 Reply Last reply Reply Quote 0
              • Chris Kawa
                Chris Kawa Moderators last edited by

                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 Reply Quote 0
                • D
                  djfm last edited by

                  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 Reply Quote 0
                  • First post
                    Last post