QListWidgetItem *item = new QListWidgetItem("Item 1"); item->setCheckState(Qt::Checked);
QListWidgetItem *item = new QListWidgetItem("Item 2"); item->setCheckState(Qt::PartiallyChecked);This code creates a new QListWidgetItem and sets its check state to PartiallyChecked. This means that the checkbox next to the item will be partially checked, indicating that some, but not all, of its sub-items are checked. The QListWidgetItem class is part of the Qt Widgets library.