Qt::CheckState state = static_cast<Qt::CheckState>(index.data(Qt::CheckStateRole).toInt());
switch (state) {
case Qt::Checked:
// do stuff
break;
case Qt::Unchecked:
// do other stuff
break;
case Qt::PartiallyChecked:
// you might have these too
break;
}
Qt::CheckState state = static_cast<Qt::CheckState>(index.data(Qt::CheckStateRole).toInt());
switch (state) {
case Qt::Checked:
// do stuff
break;
case Qt::Unchecked:
// do other stuff
break;
case Qt::PartiallyChecked:
// you might have these too
break;
}
To copy to clipboard, switch view to plain text mode
This only tells you the check state of the item the user clicked on, not any others in the tree. If you want the check state of everything in the tree then you need to iterate over the entire tree to look at each.
Bookmarks