PDA

View Full Version : Button visibility and layout participation



DiamonDogX
2nd April 2009, 13:40
I have a bunch of buttons in a horizontal row (i.e. in a QHBoxLayout). I want to be able to set one of those buttons "invisible" but still participate in the layout. When I do setVisible(false) it does set it invisible, but it respaces all the buttons in the QHBoxLayout. I want it to behave as if the button is still there, just not visible. I suppose in other words I simply want it to be transparent. Wondering what the best mechanism for achieving this is. Thanks!

Hiker Hauk
2nd April 2009, 18:23
Pseudo code,

QBoxLayout *layout;
QWidget *myWidget2Hide;
index = indexInLayout(myWidget2Hide, layout);
myWidget2Hide->hide();
layout->insertStretch(index, stretch);

Here the important things are,
a) index
b) stretch, usually set to 1, but if the other widgets have different stretches, you might want to tweak this value