PDA

View Full Version : How to make QListWidget to have enough size to show all items?



dimuz
11th September 2007, 08:31
Hello! I have a QListWidget in icon mode, it is also set to wrap its items.
In constructor of parent widget, I populate QListWidget with serveral items so they wrap to second line (and possibly third, fourth, etc).
With this scenario vertical scrollbar gets added to my QLW, while I want to somehow resize it to the size allowing to see all items at once - w/o scrollbars (I do have free space for that, so don't worry ;))

How can I achive this? I have tried to write 'qlw->resize( qlw->sizeHint() )' after populating 'qlw' with items, but this doesn't help.

Of course I can always use 'setFixedHeight()' with precalculated height, but my app is run on several OS's and maintaining different precalculated heights for each of them is a PITA :).

Any hints, guys?
Thanks in advance!

marcel
11th September 2007, 08:37
use resize(viewport()->sizeHint());

Regards

dimuz
11th September 2007, 08:57
Hmm... it returns QSize(-1,-1).