eiswand
5th December 2010, 11:10
Hello guys!
I am a total Qt beginner and I am still struggling a little bit with layouts. My 2 questions:
1) When I create a layout per code I make it like this:
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->addLayout(leftLayout);
mainLayout->addLayout(rightLayout);
setLayout(mainLayout);
I explicitly set the layout of this widget by calling setLayout(). But when I create my Window in the Qt Designer, there isn't a call to setLayout() at all! The only thing I noticed was this:
verticalLayout = new QVBoxLayout(centralwidget);
verticalLayout = new QVBoxLayout(centralwidget);
Does this line mean the centralwidget now has a vertical layout? Or is this just used for resource management (so that the layout is deleted when the centralwidget is deleted)?
2) Lets take the example from question 1: 3 buttons in a horizontal layout. I don't understand why each button has a Horizontal and Vertical Stretch AND the layout itself also has a layoutStretch (0,0,0). How are they related? Does the layoutStretch values of the QHBoxLayout override the horizontal strech values of the contained widgets?
Thanks!
I am a total Qt beginner and I am still struggling a little bit with layouts. My 2 questions:
1) When I create a layout per code I make it like this:
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->addLayout(leftLayout);
mainLayout->addLayout(rightLayout);
setLayout(mainLayout);
I explicitly set the layout of this widget by calling setLayout(). But when I create my Window in the Qt Designer, there isn't a call to setLayout() at all! The only thing I noticed was this:
verticalLayout = new QVBoxLayout(centralwidget);
verticalLayout = new QVBoxLayout(centralwidget);
Does this line mean the centralwidget now has a vertical layout? Or is this just used for resource management (so that the layout is deleted when the centralwidget is deleted)?
2) Lets take the example from question 1: 3 buttons in a horizontal layout. I don't understand why each button has a Horizontal and Vertical Stretch AND the layout itself also has a layoutStretch (0,0,0). How are they related? Does the layoutStretch values of the QHBoxLayout override the horizontal strech values of the contained widgets?
Thanks!