Unsolved Capture checkbox check/uncheck via delegates paint?
-
I've been unable to get this to work. I have a TreeView with a custom model and in my TreeView's delegate I am trying to capture if a checkbox was checked or unchecked so I added the following to the pain() method.
void MyTreeViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { // ... if (option.state & QStyle::State_Off) { std::cout << "Checkbox Unchecked!" << std::endl; } }
But this never gets called. Thoughts?
-
Hi
bool isChecked = index.data(Qt::CheckStateRole).toBool();
works for me with treeview and standarditem model.