PDA

View Full Version : Resizing QListWidget's dimensions to fit its contents



vaibhav
2nd June 2011, 13:54
Hi ,
I have frameless QListWidget with some items added to it.I don't want to set the hard coded height and width for it .It should rezie itself depending upon the contents added .
By default it doesn't resize itself to its contents.

Any help would be appreciated.

Thanks in advance .
vaibhav.

MarekR22
2nd June 2011, 14:59
1. put list widget inside of layout
2. subclass list and override QWidget::sizeHint (http://doc.qt.nokia.com/latest/qwidget.html#sizeHint-prop) (here you will provide preferred size of widget).
3. every time you suspect that preffered size should be changed (new data added to data model presented by view) call updateGeometry();