Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-3010

QListWidget::setItemWidget requires a separate call to QListWidgetItem::setSizeHint()

    XMLWordPrintable

Details

    Description

      In the following example the QListWidget is not displayed correctly unless you the sizeHint is set for the QListWidgetItem.
      If you resize the Window the QListwidget is also displayed correctly..

      Example Code:

      #include <QtGui>

      int main(int argc, char *argv[])
      {
      QApplication app(argc, argv);

      QListWidget* listwidget = new QListWidget;

      QWidget* w = new QWidget;

      QVBoxLayout* v = new QVBoxLayout( w );
      v->addWidget( new QLabel( "one" ) );
      v->addWidget( new QLabel( "two" ) );
      v->addWidget( new QLabel( "three" ) );
      v->addWidget( new QLabel( "four" ) );
      v->setSizeConstraint( QLayout::SetFixedSize );

      QListWidgetItem* item = new QListWidgetItem;
      //item->setSizeHint( w->sizeHint() );
      listwidget->addItem( item );
      listwidget->setItemWidget( item, w );

      listwidget->show();

      return app.exec();
      }

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            xcm Martin Petersson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes