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

Can't change state of checkable QListViewItem with custom widget

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 4.7.1
    • None
    • Fedora 14 running KDE 4.5.4, Qt 4.7.1

    Description

      I have a QListWidget where I am trying to add items that have a custom widget that I set with QListWidget::setItemWidget. I also wish the item to be checkable so I set the appropriate flags. Since the item is checkable a checkbox appears next to it in the list (as it should) but nothing happens when it is clicked. If I remove the call to QListWidgetItem::setSizeHint the checkbox works but the custom widget is no longer visible.

      Example code below:

      #include <QListWidget>
      #include <QListWidgetItem>
      #include <QLabel>

      int main(int argc, char** argv)
      {
      QApplication* app = new QApplication(argc, argv);
      QListWidget* listWidget = new QListWidget();
      QListWidgetItem* item = new QListWidgetItem();
      item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
      item->setCheckState(Qt::Unchecked);
      listWidget->addItem(item);
      QWidget* widget = new QLabel("Label");
      item->setSizeHint(widget->sizeHint());
      listWidget->setItemWidget(item, widget);

      listWidget->show();
      app->exec();
      }

      Attachments

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

        Activity

          People

            vfm Thierry Bastian (closed Nokia identity) (Inactive)
            pafcu Stefan Parviainen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes