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();
}