I am using QListWidgetItem to add Items in my QListWidget.
In some situations, I want some rows of my QListWidget become non selectable. (I mean I want some QListWidgetItem to be non selectable)
Is ther any way to do this?
PS: I tried
listWidgetItem->setFlags(Qt::NoItemFlags) listWidgetItem->setSelected(false); but they don't disable the selection of items.
Edit:
QStringList _strListClients = _strClients.split(",",QString::KeepEmptyParts,Qt::CaseInsensitive); for(int i = 0; i < _strListClients.count(); i++)//Add Client's Check Boxes { QListWidgetItem* _listWidgetItem = new QListWidgetItem(_strListClients[i], listWidgetClients); listWidgetClients->addItem(_listWidgetItem); if(_strListClients[i] == "Unknown"){ _listWidgetItem->setSelected(false); _listWidgetItem->setTextColor(Qt::red); _listWidgetItem->setFlags(_listWidgetItem->flags() & ~Qt::ItemIsSelectable); } }