PDA

View Full Version : Detect clicking on checkbox inside a dynamic-populated QTreeWidget



tkm
11th January 2011, 09:00
I've a QTreeWidget whereby the QTreeWidgetItems are added using web-services.
I've reimplemented the mousePressEvent to detect whether the expansion sign of a QTreeWidgetItem is being clicked. If so, a custom signal will be emitted, connecting to a slot. In this slot, I will check for this item's isExpanded(). If it is not expanded, I will use web service to retrieve the data to add as QTreeWidgetItem inside this item.
The population part is working. However, every QTreeQidgetItem has a checkbox. I need to detect when a checkbox is clicked. This is because I want to recursively check all child checkboxes if a parent checkbox is clicked. And recursively uncheck all parent checkboxes if a child checkbox is clicked.
I cannot use itemChanged signal as it will be emitted whenever a change occurs. Therefore adding QTreeWidgetItem will emit itemChanged.

Any idea of how to detect when a checkbox in a QTreeWidget is clicked? Is there a way to detect only checkbox click during mousePressEvent?