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
) {
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);
}
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);
}
To copy to clipboard, switch view to plain text mode
Is it this way, which I use to do this, wrong or it is something else?
Bookmarks