Qt5: Styling the checkbox of a checkable QTreeWidgetItem
-
In my app I have stylesheets for
QCheckBox
. I created aQTreeViewWidget
withQTreeWidgetItems
that has been made checkable by setting the flagQt::ItemIsUserCheckable
.I was expecting that the checkbox that is displayed will by styled according to the already existing
QCheckBox
styles. Unfortunately that doesn't happen. This begs the question: how to 'access' that checkbox of theQTreeWidgetItem
s?I tried
QTreeView::item
as well asQTreeView::indicator
and also the combinationQTreeView::item::indicator
, none of which seem to function. So what is the correct syntax? -
As it turned out, one must explicitly say
QTreeView::indicator:unchecked
in order to set the general settings like background color for this checkbox. That was a bit surprising, as this is not needed for instance forQCheckbox::indicator
orQGroupBox::indicator
, but the solution is now here for posterity