PDA

View Full Version : Tristate Flag ignored in QListWidgetItem



ghoust26
16th April 2008, 08:21
I trying to make a QListWidget which contain items which is checkable and they have tristate.
I set flag Qt::ItemIsTristate on items but when running program it is still possible to set them only in two state Qt::Checked or Qt::Unchecked by clicking on item.

I try to do this in this way:



void step1display::addProductItem(QString programName, QString data, bool status)
{
QListWidgetItem *newItem = new QListWidgetItem(programName, ui.listProgramsAll, 0);
newItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsTristate);
newItem->setData(32, data);
if (status) {
newItem->setCheckState(Qt::PartiallyChecked);
}
else {
newItem->setCheckState(Qt::Unchecked);
}
ui.listProgramsAll->addItem(newItem);
}


Is it this way, which I use to do this, wrong or it is something else?