Spacers and Layouts
-
I have just started out Qt from the book "C++ GUI programming with Qt4". I have some basic doubts 1.) What is the role/purpose of Spacers in designing the layouts? 2.) In the SortDialog prorgam, thelayout()->setSizeConstraint(QLayout::SetFixedSize); gives me a segmentation fault. I am not able to solve the problem. Without this line, the code works perfectly. 3.) What is a Top Level Layout? pls help...thnx
-
-
Spacers
In short words: These keep things apart that would otherwise be glued together by the layout. I'd suggest you play around with Qt Designer - you will have immediate visual feedback. It's very easy to understand then. -
Segfault
Hard to comment without the source code. But a segfault is almost always on a null pointer, so it is very likely that you forgot to set the layout. Also, is "thelayout()" really a method? -
Toplevel Layouts
This is the layout that is applied to the widget. You will almost always have some further layouts, that are included in the toplevel layout.
-
-
thnx for the reply...
thelayout was a typo. it should be layout()->.....
does setting the layout in Qt Designer mean i just have to lay out the widgets in a specified order, like Lay out Horizontally / Vertically ? . Does setting this mean setting a Top Level Layout. -
Layout are designed to automatically forming objects positions when resizing the form or its parent.
[quote author="saurabhsood" date="1294852671"]thnx for the reply...
thelayout was a typo. it should be layout()->.....
does setting the layout in Qt Designer mean i just have to lay out the widgets in a specified order, like Lay out Horizontally / Vertically ? . Does setting this mean setting a Top Level Layout. [/quote] -
[quote author="saurabhsood" date="1294852671"]thnx for the reply...
thelayout was a typo. it should be layout()->.....
does setting the layout in Qt Designer mean i just have to lay out the widgets in a specified order, like Lay out Horizontally / Vertically ? . Does setting this mean setting a Top Level Layout. [/quote]Did you read the Qt docs on layouts already?
- "Layout Management":http://doc.qt.nokia.com/4.7-snapshot/layout.html
- "Widgets and Layouts":http://doc.qt.nokia.com/4.7-snapshot/widgets-and-layouts.html#layouts
- "Widgets Tutorial - Using Layouts":http://doc.qt.nokia.com/4.7-snapshot/tutorials-widgets-windowlayout.html
- "Widgets Tutorial - Nested Layouts":http://doc.qt.nokia.com/4.7-snapshot/tutorials-widgets-nestedlayouts.html
- "A Quick Start to Qt Designer":http://doc.qt.nokia.com/4.7-snapshot/designer-quick-start.html
- "Layout Examples":http://doc.qt.nokia.com/4.7-snapshot/examples-layouts.html