PDA

View Full Version : How QCheckBox into QListWidgetItem?



Teuniz
23rd July 2007, 12:39
Can somebody show some examplecode about how to insert a QCheckBox into
a QListWidgetItem?

Thanks.

marcel
23rd July 2007, 13:09
It is easy enough. Use QListWidget::setItemWidget(QListWidgetItem*, QWidget*);
Something like:


myList->setItemWidget(someListItem, new QCheckBox("checkBox"));


Note that you need a reference to the item for which you want to set the widget.

Regards

jpn
23rd July 2007, 13:11
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
item->setCheckState(Qt::Unchecked);

Please search the forums next time. This subject has been discussed several times. ;)

Teuniz
23rd July 2007, 21:31
Tnx, I didn't expect that it should be that simple :o