Abdu
Abdu

Reputation: 135

How to I resize an item in a QListWidget upon the resize of the window?

I am using a QStyledItemDelegate to change the appearance of the QListWidgetItems in my QItemWidget. I want to change the height of the items depending on the size of the text. I am using sizeHint() which works fine on the initial creation. The problem is when the window resizes, the text reformats and leaves empty spaces. How do I resize the items to remove the empty space?

On initial

After resizing

Upvotes: 2

Views: 617

Answers (1)

Abdu
Abdu

Reputation: 135

setResizeMode to QListView::Adjust instead of QListView::Fixed.

Upvotes: 3

Related Questions