PDA

View Full Version : Problem with QListWidget Updating



flob
20th November 2009, 13:34
Hi All,

In Qt 4.5.3, I am using a standard QListWidget as part of a mainwindow. It is being populated by QListWidgetItems (addItem), each of which is then linked against a custom widget (addItemWidget). When an item is selected from the list (QListWidget::itemClicked signal), I show the custom widget. The custom widget is subsequently hidden when focus changes to another item (QListWidget::currentItemChanged signal).

The problem I am having lies in that the custom widget is significantly greater in height than the list widget's items (specifically, I've forced the list widget's items to a height of 30, and the custom widget has a height of 80). When the custom widget is shown, it covers up the list items below it. I would to know how to make the QListWidget update its layout to accommodate the changing item/widget heights.

Help?

Thanks.

high_flyer
20th November 2009, 16:56
wont resize() help?

flob
21st November 2009, 17:05
No, resize() didn't do it...

I ended up forcing a layout update by calling setFlow(QListView::TopToBottom).

I guess what I needed was a way to either call updateLayout or emit the layoutChanged signal... however, even though I would have access to those methods from QListView, it was hidden from me as a QListWidget. As it was, I didn't need all the extras of subclassing item views or models, so ...dunno if that's the solution, per se, but at least it's updating as needed.

Now to see how that performance is affected when I stick the application on my embedded device. Ugh.

Thanks!