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. Layouts in QtCreator for beginners

Layouts in QtCreator for beginners

Scheduled Pinned Locked Moved General and Desktop
10 Posts 5 Posters 12.8k 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.
  • Y Offline
    Y Offline
    Ygramoel
    wrote on last edited by
    #1

    I'm new to designing user interfaces with Qt and I am having a hard time trying to define the layout of my gui in QtCreator.

    Can anyone point me to some decent documentation on how to use layouts in QtCreator?

    For example, I have a group box containing a number of buttons and labels arranged more or less on a grid. When I apply a grid layout to the group box, a number of things happen that I don't understand and don't want to happen:

    • the size of the group box changes, even though the size policy of the group box is fixed,fixed
    • the size of some of the buttons changes, even though their size policy is again fixed,fixed.
    • I cannot find a way to add rows or columns to the layout

    A hint or pointer to documentation would be very useful.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mark.eastonregenersis.com
      wrote on last edited by
      #2

      You need to set the 'minimum' sizes of your objects before applying layouts I noticed.

      1 Reply Last reply
      0
      • W Offline
        W Offline
        Woody
        wrote on last edited by
        #3

        Maybe this link will get you started: "Qt 4.7: Tutorials":http://doc.qt.nokia.com/4.7-snapshot/tutorials.html and "Videotutorials":http://www.voidrealms.com/tutorials.aspx?filter=qt

        File not found. Nobody leave the room!

        1 Reply Last reply
        0
        • R Offline
          R Offline
          Rahul Das
          wrote on last edited by
          #4

          You can start with [[doc: layout]] :) :)


          Declaration of (Platform) independence.

          1 Reply Last reply
          0
          • W Offline
            W Offline
            Woody
            wrote on last edited by
            #5

            That idd is maybe easier. Though if you are new to Qt, the links I provided will help you in the beginning.

            File not found. Nobody leave the room!

            1 Reply Last reply
            0
            • Y Offline
              Y Offline
              Ygramoel
              wrote on last edited by
              #6

              Mark,

              Thanks for the hint on using a minimum size; this was the key problem that was bogging me. I intuitively assumed that using a size policy of "fixed" would freeze the size of my widgets, but this is clearly not the case.

              Woody,

              Thanks for the link; I am still reading to try and understand why my intuitive interpretation was not correct, and how these layouts really work. It is not really intuitive to me.

              Rahul,

              The "layout" link explains layout in terms of Qt classes, whereas I was really looking for an explanation of layouts in Qt Designer. Anyway, it is still useful background information.

              1 Reply Last reply
              0
              • Y Offline
                Y Offline
                Ygramoel
                wrote on last edited by
                #7

                The "Qt Designer documentation about layouts":http://doc.qt.nokia.com/4.7/designer-layouts.html does not explain size policies; it seems necessary to delve into the documentation of the "QSizePolicy class":http://doc.qt.nokia.com/4.7/qsizepolicy.html#details.

                From the QSizePolicy documentation, one can learn that a sizePolicy works relative to the sizeHint, and not to the current size as I intuitively expected.

                How the size hint is defined for widgets like push buttons and labels is not obvious from the "documentation":http://doc.qt.nokia.com/4.7/qwidget.html#sizeHint-prop ; it seems to be unspecified by default, and the relationship to minimum and maximum size is not clear. I also checked the documentation for a derived class like "QPushButton":http://doc.qt.nokia.com/4.7/qpushbutton.html#sizeHint , but there is no extra information there.

                My conclusion is that the Qt documentation could use some improvements there. In the mean time, I guess I'll just have to experiment to find out how it works.

                One of the open questions for me is how a grid layout assigns widgets to rows and columns. There seems to be some sophisticated heuristics involved (or just magic?), but it is unclear how to fix things if it doesn't do what I want.

                1 Reply Last reply
                0
                • W Offline
                  W Offline
                  Woody
                  wrote on last edited by
                  #8

                  But if you do use Qt Designer, can't you experiment a bit? Make things larger, smaller, fix the window size and see what happens.

                  I do the same for my project, just experiment, see where I end.

                  File not found. Nobody leave the room!

                  1 Reply Last reply
                  0
                  • Y Offline
                    Y Offline
                    Ygramoel
                    wrote on last edited by
                    #9

                    Yes of course I can experiment, I have experimented and I will experiment. Its just that when I don't get the results I want while experimenting, I try to understand better what is happening and how to get the desired results. That's why I started looking for help and reading documentation ...

                    1 Reply Last reply
                    0
                    • N Offline
                      N Offline
                      needhelp_gh
                      wrote on last edited by
                      #10

                      I found this useful when I was beginning to learn about layouts: "http://www.informit.com/articles/article.aspx?p=1405224&seqNum=4":http://www.informit.com/articles/article.aspx?p=1405224&seqNum=4


                      http://abstrusegoose.com/432

                      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