Important: Please read the Qt Code of Conduct -

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?

  • Lifetime Qt Champion

    bool isChecked =;
    works for me with treeview and standarditem model.

Log in to reply