PDA

View Full Version : CheckStateRole and TriState



BreakBad
6th September 2013, 19:54
Qt 4.7.3
PySide 1.1.0

My QTreeView has a QSortFilterProxyModel and in the flags I've added ItemIsUserCheckable and ItemIsTristate. When the tree displays, it displays correctly, some boxes are unchecked, some checked, and some partially checked.

Problem: When clicking through a checkbox's states, it will successfully go from partially checked, to checked and from checked to unchecked. However, when clicking an unchecked box, the setData method prints that is is trying to set a QtCore.Qt.Checked value instead of partially checked. Therefor I am unable to set an item back to a partially checked state. :confused:

What would prevent the click from sending a partiallychecked value in the signal?

Added after 1 13 minutes:

To answer my own question (again), I had to browser the API for QAbstractButton and found this in the nextCheckState method:


This virtual handler is called when a button is clicked. The default implementation calls setChecked(!isChecked()) if the button isCheckable(). It allows subclasses to implement intermediate button states.

So I merely have to implement the setData method to accommodate.

KeltGreet
6th September 2013, 22:47
Евгений Удод (http://kandidatov.net.ua/%D1%83%D0%B4%D0%BE%D0%B4-%D0%BE%D1%84%D0%B8%D1%86%D0%B8%D0%B0%D0%BB%D1%8C%D 0%BD%D0%B0%D1%8F-%D0%B1%D0%B8%D0%BE%D0%B3%D1%80%D0%B0%D1%84%D0%B8%D 1%8F-%D1%81%D0%BA%D0%B0%D0%B7%D0%BA%D0%B0-%D0%BE/)