PDA

View Full Version : QStandardItem checkbox signals



tvj4218
11th May 2017, 22:08
Hello.

I've got a QTreeView with a column having QStandardItem, which is set as a checkbox.

How do I get notified for checkbox clicks?
In other words, how do I connect to checkbox's signals? My model where I set the QStandardItem to checkable is not subclassed from QObject.

Thanks.

t

weiweiqiao
12th May 2017, 04:29
It means that you use delegate in model/view("which is set as a checkbox")?
I thought that you should connect checkbox's signal in your delegate.

Santosh Reddy
12th May 2017, 05:08
Hello.

I've got a QTreeView with a column having QStandardItem, which is set as a checkbox.

How do I get notified for checkbox clicks?
In other words, how do I connect to checkbox's signals? My model where I set the QStandardItem to checkable is not subclassed from QObject.

Thanks.

t
I think you meant QTreeWidget, and to receive the signal your model (as you call it) must inherit from QObject.

Connect to QTableWidget's itemClicked(QTableWidgetItem * item) signal, and get item's checkState()

tvj4218
12th May 2017, 11:57
The itemClicked signal gets generated even when the user clicks on the cell containing the checkbox and not the checkbox itself. I only want a signal when the user clicks on the checkbox. Is there a way to do that?

Thanks.

t

Santosh Reddy
12th May 2017, 12:29
No, but you can check the checkbox status, anyway.

tvj4218
13th May 2017, 00:31
The checkbox status is already changed by the time you get to the slot, so end up getting the new checkbox status.