QListWidgetItem* item = new QListWidgetItem("Checked Item"); item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); item->setCheckState(Qt::Checked);
QListWidgetItem* item = new QListWidgetItem("Unselectable Item"); item->setFlags(item->flags() & ~Qt::ItemIsSelectable);
QListWidgetItem* item = new QListWidgetItem("Disabled Item"); item->setFlags(item->flags() & ~Qt::ItemIsEnabled); item->setToolTip("This item is disabled.");In this example, a QListWidgetItem is created with the text "Disabled Item" and then the enabled flag is removed. This means that the item cannot be interacted with by the user. Additionally, a custom tooltip is set to inform the user of the item's disabled state. These examples use the Qt library, specifically the QtCore and QtGui modules.