Important: Please read the Qt Code of Conduct -

QTreeView click problem

  • I use QTreeview with QStandardItemModel. for some reason I used a stylesheet to hide branch image, and set QStandardItem Icon with mine. I connect clicked(QModelIndex) signal with sltOnItemClicked(QModelIndex index) function to solve the expand and collapse problem. Displaying checkboxes is also needed, I do not use follow code connect(model, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(onItemChanged(QStandardItem*)));, as it caused my program crash, so I deal it in sltOnItemClicked(QModelIndex index) function. my problem is how to know the mouse click on the checkbox, then I can deal with these issues separately.

  • Lifetime Qt Champion

    I think you can hookup to QAbstractItemModel::dataChanged
    and check the "checkbox" state there.

Log in to reply