PDA

View Full Version : Overriding a widget with another in a layout



hml
4th July 2010, 21:10
Hi,

I have a main layout which contains a QListWidget and a QWidget that depends on the selected row in the QListWidget.
I store the list of QWidget in a local array, 1 QWidget for each row in the list.
I connected the currentTextChanged signal of QListWidget to my custom slot, where I remove the widgets whose rows are not selected from the layout, then add the widget whose row has just been selected using ->currentRow() from QListWidget and removeWidget and addWidget from QLayout

Initally, widgets seem to change but they'd appear on top of each other (messing up the display). I added setAutoFillBackground(true) for those widgets, but now on changing selection in the list, nothing appears to happen, though debugging shows the correct widget is removed and the right one added.

rds,

SixDegrees
5th July 2010, 10:19
Try using a QStackedWidget (http://doc.qt.nokia.com/4.5/qstackedwidget.html)

hml
5th July 2010, 21:53
thanks very much,
worls like a charm,