[SOLVED] widgets moving after setVisible(false) in aQLayout
Hello,
I very much like Qt, witch works very well for me up to now, and allow fast coding!
I have a very simple pb tough :
Given some widget displayed in a layout, i would like to hide some of them without moving others, in a QVBoxlayout for example.
I did not find the answer of this elementary pb.
Thanks in advance.
dmcr
Re: widgets moving after setVisible(false) in aQLayout
Consider putting a spacer along with the item in a separate V or H layout, and then adding this layout to your main layout. This way the spacer would fill all the free space when the item is hidden.
Re: widgets moving after setVisible(false) in aQLayout
//this not so obvious thing for me was not so long!
QWidget *abWidget::createWidgetWithSpacer( QWidget* w)
{
QWidget *wdgt = new QWidget;
QHBoxLayout *l = new QHBoxLayout;
l->addWidget( w, 0, Qt::AlignCenter ) ;
l->addSpacing(w->width());
wdgt->setLayout(l);
return wdgt;
}