PDA

View Full Version : QStackedLayout and setContentsMargins()



Carlsberg
15th November 2012, 07:07
setContentsMargins() seems to not have any effect on QStackedLayout.

This code results in no margin:



mainLayout = new QStackedLayout(this);
mainLayout->setContentsMargins(20, 20, 20, 20);
mainLayout->addWidget(image);
mainLayout->addWidget(text);
mainLayout->setCurrentIndex(0);


while this has the correct 20 pixels margin



QVBoxLayout* mainLayout = new QVBoxLayout(this);
mainLayout->setContentsMargins(20, 20, 20, 20);
mainLayout->addWidget(image);


Any idea how I can have the margin on QStackedLayout?

Thanks

wysota
15th November 2012, 15:47
Put it inside a QVBoxLayout with a contentsMargin. Or use QStackedWidget.