I added
// where QStandardItemModel *model = new QStandardItemModel();
connect(model, SIGNAL(itemChanged(QStandardItem * item)), SLOT(myItemChanged(QStandardItem *item)));
// where QStandardItemModel *model = new QStandardItemModel();
To copy to clipboard, switch view to plain text mode
from my MainWindow (inherits from QMainWindow) and
{
changeItemState(item);
}
{
if (!item)
return;
for (int i=0; i<item->rowCount(); ++i) {
child->setCheckable(item->checkState());
changeItemState(child);
}
}
void MainWindow::myItemChanged(QStandardItem *item)
{
changeItemState(item);
}
void MainWindow::changeItemState(QStandardItem *item)
{
if (!item)
return;
for (int i=0; i<item->rowCount(); ++i) {
QStandardItem *child = item->child(i);
child->setCheckable(item->checkState());
changeItemState(child);
}
}
To copy to clipboard, switch view to plain text mode
similar to your example but the two methods weren't invoked at all when I toggle the checkbox.
Bookmarks