QTreeView: "Auto-Checkboxes" and "Checkbox only"?
-
Hello,
Other than overriding the flags() and data(Qt::CheckState) members of my QAbstractItemModel based model, is there a way to induce QTreeView to render checkboxes (and tristate boxes) for certain columns of my model? If so, how? Can it be based on datatype returned by data(Qt::DisplayRole)?
Secondly, when QTreeView renders a checkbox, it also seems to leave an area for text. It's even editable(!). How can just render the checkbox?
Thank you
-
Gerolf,
Yeah, I've got the check boxes by setting those flags on my data model.
To clarify: I was wondering if there was a different way, since the choice of how to render a given data type would seem the responsibly of the view, not the model.
Something like:
@
treeView->setColumnRenderRule(colNum1, QTextRenderRule);
treeView->setColumnRenderRule(colNum2, QCheckboxRenderRule);
@or even:
@
treeView->setCellRenderRule(QBool, QCheckboxRenderRule, optionalColumnNumber);
@