tags:

views:

51

answers:

1

When I try to change the location of a layout with setParent the result is non-functional or odd.

the following works:

ui.txDiag_1->setParent(ui.tab_2);
movingHlayout = new QVBoxLayout(ui.tab_2);
movingHlayout->setSpacing(3);
movingHlayout->setMargin(3);
movingHlayout->setObjectName(QString::fromUtf8("movingHlayout"));
movingHlayout->addWidget(ui.txDiag_1);

but this doesnt(movingHlayout has been constructed before hand):

ui.txDiag_1->setParent(ui.tab_2);
movingHlayout->setParent(ui.tab_2);
movingHlayout->setSpacing(3);
movingHlayout->setMargin(3);
movingHlayout->setObjectName(QString::fromUtf8("movingHlayout"));
movingHlayout->addWidget(ui.txDiag_1);
+2  A: 

You possibly have to call setLayout() on the widget you are setting the layout up in.

http://doc.qt.nokia.com/4.6/qwidget.html#setLayout

As you can see from the docs, the ownership of the layout will automatically be set to the target widget.

BastiBense
thx I will try that
yan bellavance
still doesnt work
yan bellavance
it works once then it doesnt work anymore
yan bellavance