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. 2 horizontal layouts, 1 with fixed height
Forum Updated to NodeBB v4.3 + New Features

2 horizontal layouts, 1 with fixed height

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 5.7k 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.
  • W Offline
    W Offline
    WhatIf
    wrote on last edited by WhatIf
    #1

    I'm using Qt Designer to create a page with a navigation bar (using buttons at the top of the page inside a horizontal layout) and a message in the lower horizontal layout. The problem I'm having is the 2 layouts take half of the screen each. I want the top horizontal layout to have a fixed height and the lower one to take the remaining screen. I don't seem to find any property in the horizontal layout that can fix this problem in Design mode.

    How can I have 2 layouts, one with fixed size?

    Here is an image to help visualize it

    http://i.stack.imgur.com/zCkeh.png

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      you can use LayoutStretch 2,1 to share other than half/half.
      That said, you set minimum size on the widget you insert into the layout
      so for your design, the top bar,you would set MInimumHeight to say 64
      and it would not get bigger.

      So with layouts, u set constraints on the widgets, not on the layouts.

      W 1 Reply Last reply
      0
      • mrjjM mrjj

        Hi
        you can use LayoutStretch 2,1 to share other than half/half.
        That said, you set minimum size on the widget you insert into the layout
        so for your design, the top bar,you would set MInimumHeight to say 64
        and it would not get bigger.

        So with layouts, u set constraints on the widgets, not on the layouts.

        W Offline
        W Offline
        WhatIf
        wrote on last edited by
        #3

        @mrjj

        For some reason it's not working so I will list what I do step by step :

        1. I have QStackedWidget with contains 2 pages (page 2 is the one that will have the 2 layouts )

        2. drag and drop 2 horizontal layouts into page2

        3. selected page 2, right-click, choose layout, lay out vertically (at this point each of the layout fill out half of the screen)

        4. when I select the top layout and change LayoutStretch to 1, the bottom layout changes LayoutStretch automatically to 0. If I change the bottom layout to 2 and select the top layout to check its value I find that it was automatically changed to 2. If I go back to the bottom layout I find that LayoutStretch is 0.

        5. drag and drop a button in the top layout and change it's maximum size to width = 125 and height = 60, has no effect on the top layout, still takes half of the screen.

        What am I still doing wrong?

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #4
          1. You should no drag layout to page. Its rarely use standalone.
            Right click is the way to add layout.

          Try this

          Create page 3. ( so we have clean to play with)
          Drag 2 widgets to it.
          Right click the page and select the Vert layout.
          (widgets should spit it half/half)
          Now click on top widget
          and set its Maximum Height to 64.
          It should be top bar aliek now. place buttons etc in it.

          ps. and dont worry. layout are kinda strange to learn at first. later they be your best friends.

          W 1 Reply Last reply
          0
          • mrjjM mrjj
            1. You should no drag layout to page. Its rarely use standalone.
              Right click is the way to add layout.

            Try this

            Create page 3. ( so we have clean to play with)
            Drag 2 widgets to it.
            Right click the page and select the Vert layout.
            (widgets should spit it half/half)
            Now click on top widget
            and set its Maximum Height to 64.
            It should be top bar aliek now. place buttons etc in it.

            ps. and dont worry. layout are kinda strange to learn at first. later they be your best friends.

            W Offline
            W Offline
            WhatIf
            wrote on last edited by
            #5

            @mrjj

            Using 2 widgets instead of horizontal layouts worked but it has its problems.

            First, I like the layout to be wrap around multiple buttons to keep them lined up perfectly.

            Second, if I resize the window a few of the buttons disappear.

            Is there a way to get around those 2 problems?

            mrjjM 1 Reply Last reply
            0
            • W WhatIf

              @mrjj

              Using 2 widgets instead of horizontal layouts worked but it has its problems.

              First, I like the layout to be wrap around multiple buttons to keep them lined up perfectly.

              Second, if I resize the window a few of the buttons disappear.

              Is there a way to get around those 2 problems?

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #6

              @WhatIf
              just give the top widget a layout too
              so u can control the buttons. like a Horz or Grid one.

              Im not sure what means
              " layout to be wrap around multiple buttons"
              as buttons are inserted into a layout.

              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