0

I have created QTableView and add an QStandardItem checkbox into with this code:

....
QStandardItem *chkItem = new QStandardItem(true);
chkItem->setCheckable(true);
chkItem->setData(Qt::AlignCenter, Qt::TextAlignmentRole);
tblModel->appendRow(chkItem);
...

where tblModel is QStandardItemModel.

Now i wonder how can i catch the checkbox changed state event?

I have tryed catch the table click event but this is triggered every times user click on a cell (i have no idea to know whether the checkbox state has changed or not). Please give me a way to solve this problem.

Bình Nguyên
  • 2,252
  • 6
  • 32
  • 47
  • This should answer it: https://stackoverflow.com/questions/2785434/how-to-interact-with-checkbox-actions-qtableview-with-qstandarditemmodel?rq=1 – Hephaestus Feb 02 '18 at 20:31

1 Answers1

0

Try QStandardItem::checkState() to retrieve the Qt::CheckState of the checkbox. If you need to know, if the state changed, then save the old state somewhere and check if the state changed on the click event.

Ralph Tandetzky
  • 22,780
  • 11
  • 73
  • 120