Search code examples
qtqlistwidgetqlistview

How to set minimum height of QListWidgetItem?


How can I set the minimum height of a QListWidgetItem? I'm using QListWidget::setItemWidget() with a customized widget, and although I explicitly declared minimum height of my customized widget, those QListWidgetItems still have a pretty low height attribute.


Solution

  • Use setSizeHint on the items.

    void QListWidgetItem::setSizeHint ( const QSize & size )
    

    This is the right method for telling the delegate how much screen it must preserve for the item.

    Look at http://qt-project.org/doc/qt-4.8/qlistwidgetitem.html#setSizeHint