O'Reilly logo

Programming with Qt, 2nd Edition by Matthias Kalle Dalheimer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. Using Layout Managers

So far, we have laid out our widgets in a very basic manner. We have set absolute positions and sizes with QWidget::resize and QWidget::move() or QWidget::setGeometry(), and we have specified the position within the parent and the size at which a widget should be shown. This process is generally not desirable. It makes the window that contains the widgets (often a dialog box) look bad when it is resized. If the size of this window is increased, an empty space will appear at the right and lower borders of the window because the widgets stay at their fixed positions and do not fill the newly available space. If, on the other hand, the size of the window is decreased, some widgets will not be visible any longer, or the window might appear incomplete. Again, this occurs because the widgets do not occupy less space and use less intrawidget space to accommodate the smaller parent window.

Another disadvantage comes from internationalization. When you prepare your program to display text in different languages, on-screen text in different languages are rarely the same size. If you design your dialog boxes with English labels and then have your application translated into a language such as Finnish, in which the average word length is long, the text will probably not fit into the allocated space.

Layout Manager Basics

The solution to these two problems is geometry management, also called layout management. When using geometry management, sizes and positions ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required