How to update QListWidgetItem geometry.
-
Hello
I am using QListWidget to have a list of widgets. to fill this list I use QListWidgetItem and set sizeHint to it.listWidget_ = new QListWidget(this); void addWidgetToList(QWidget *widget) { QListWidgetItem wItem = new QListWidgetItem(listWidget_); wItem -> setSizeHint(widget -> sizeHint()); listWidget_ -> addItem(wItem); wItem -> setItemWidget(widget); }
on other part of code I need to change the sizeHint of items and I set different sizeHints to all items in list.
but they don't update the geometry but wItem -> sizeHint() shows new correct value.
I tried to call update, layout() -> invalidate/activate, updateGeometry repaint but they didn't affect.
any idea? -
Hi,
Why not use a QScrollArea for that ?
A container QWidget with a QVBoxLayout on it and you have pretty much the behavior you want without having to play with the item size hint.
-
The widget
sizeHint
is probably not that important to the QListWidget.It might be worth switching to a custom delegate instead... see QStyledItemDelegate