Sorry to resume this old thread, but I can't make CheckableProxyModel work with Qt 5.2.
I downloaded from git@gitorious.org:checkableproxymodel/checkableproxymodel.git the lastest version but I couldn't select or deselct the items on the treeview for the bundled example. The only changes I made was for QT5 compatibility (QT += widgets in .pro file and #include <QApplication> instead of QtGui/QApplication)
Anyone succeded on using this class with QT 5.2 ?
EDIT : I forgot to explain where the problem lies and when it occours. It happens only for directories and not files in the treeview.
The part of CheckableProxyModel which behaves differently is
@
CheckableProxyModel::TreeCheckState treeState(CheckableProxyModel::Checked);
if (state == Qt::Unchecked) {
treeState = CheckableProxyModel::Unchecked;
} else if (state == Qt::PartiallyChecked) {
qWarning() << "Unexpected new tree state.";
return false;
}
@
It constantly prints the "Unexpected new tree state." string.
By setting the
@CHECKABLEPROXYMODEL_DEBUG@
define the state is set to 2 (which corresponds on PartiallyChecked on the enum Qt::CheckState)
After some invstigations, I've seen that the differences in 5.1.1 source and 5.2.0 for QItemDelegate may be the source of this problem, in particular
For QT 5.1.1
@QItemDelegate::editorEvent(....){
...
...
Qt::CheckState state = (static_castQt::CheckState(value.toInt()) == Qt::Checked
? Qt::Unchecked : Qt::Checked);
return model->setData(index, state, Qt::CheckStateRole);
}
@
while for QT 5.2.0 is
@QItemDelegate::editorEvent(....){
...
...
Qt::CheckState state = static_castQt::CheckState(value.toInt());
if (flags & Qt::ItemIsTristate)
state = ((Qt::CheckState)((state + 1) % 3));
else
state = (state == Qt::Checked) ? Qt::Unchecked : Qt::Checked;
return model->setData(index, state, Qt::CheckStateRole);
}
@
Thank you in advance