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. Layout Horizontally
Forum Update on Monday, May 27th 2025

Layout Horizontally

Scheduled Pinned Locked Moved General and Desktop
13 Posts 7 Posters 6.4k 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.
  • S Offline
    S Offline
    szh1
    wrote on last edited by
    #1

    I have a QMainWindow with 2 QTreeViews, next to each other horizontally. The one on the left is smaller than the one on the right. But when I choose Layout Horizontally, they automatically become equal sizes. How can I keep the one on the right bigger than the one on the left?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Sorin
      wrote on last edited by
      #2

      I think that YourTreeView->setMaximumSize could help you with what you want

      There are only 10 types of people in the world: Those who understand binary, and those who don't

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

        Try to use horizontalStretch

        1 Reply Last reply
        0
        • S Offline
          S Offline
          szh1
          wrote on last edited by
          #4

          Thanks for the answers. Sorin's answer works if you want one of the QTreeViews not to get bigger than a certain size (like in my case). Denis Kormalev's answer is good if you want to keep them proportionate to each other.

          Thanks!

          1 Reply Last reply
          0
          • M Offline
            M Offline
            MTK358
            wrote on last edited by
            #5

            Or you can use a splitter and let the user choose the relative sizes of the tree views.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              szh1
              wrote on last edited by
              #6

              Good idea

              1 Reply Last reply
              0
              • T Offline
                T Offline
                TigerTony
                wrote on last edited by
                #7

                Hi.
                My situation is exactly the same and i like to use QSplitter in this scenario.

                But HOW do i achieve this with QDesigner???

                In the "Layout" submenue of the context menu of QMainWindow in the object view, the two optiones with splitter are grey/inactive - in the toolbar, too. wtf?

                How can i actually use them?

                And yes, there is one widget inside "centralwidget" - two widgets dont help either.

                Thanks
                L.

                PS: Using QDesigner 4.7.0 on Windows.

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  giesbert
                  wrote on last edited by
                  #8

                  The splitter itself is a widget.

                  SO select the widgets you want to use in the splitter, layout them by the splitter and put a V or HBoxLayout on the main window.
                  Or use the splitter as central widget.

                  Nokia Certified Qt Specialist.
                  Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    TigerTony
                    wrote on last edited by
                    #9

                    Hi Gerolf.
                    Thanks for your answer.

                    But in my opionion you missed the point. Sorry. But i forgot to mention, there is no Splitter widget in QDesigner wigdet toolbox!

                    The question remains, how do i do this with QDesigner 4.7.0 ?

                    Or do i just dont get it?

                    Thanks
                    Lars

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

                      Got the "Form" menu and select "Lay Out Horizontally in a Splitter".

                      And read "this":http://doc.qt.nokia.com/4.7/designer-quick-start.html, "this":http://doc.qt.nokia.com/4.7/designer-layouts.html and "this":http://doc.qt.nokia.com/4.7/designer-manual.html

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

                      1 Reply Last reply
                      0
                      • T Offline
                        T Offline
                        TigerTony
                        wrote on last edited by
                        #11

                        Ok, got it now.

                        I didnt know that i actually need two "layouts" in the right order. (Though the splitter is no real layout, i know).

                        First the splitter "layout" on the two wigdets. Then the layout of the main window (for dynamic resizing of the widgets).

                        A always applied the layout of the main window first, but then your stuck. And there is no splitter option in the first place.

                        Thanks a lot.

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

                          Nice, that it works now.

                          You're right, the order of layouts is important, but easy to memorize: Always layout from the inner pieces to the outer, single widgets to groups, groups to bigger groups and the toplevel layout at the very end.

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

                          1 Reply Last reply
                          0
                          • T Offline
                            T Offline
                            TigerTony
                            wrote on last edited by
                            #13

                            And now Gerolfs post makes sense to me.

                            Sorry.

                            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