Dear All,
I have a plain QTreeView, and I want to display some of the icons as greyed
depending on some state of the model items
So I have subclassed QStyledItemDelegate :
class SceneObjectsDelegate : public QStyledItemDelegate
{
public:
explicit SceneObjectsDelegate(QObject *parent = nullptr) :
QStyledItemDelegate(parent) {}
protected:
void initStyleOption(QStyleOptionViewItem *option, const QModelIndex
&index) const override
{
QStyledItemDelegate::initStyleOption(option, index);
int flags = index.data(RefTreeModel::FlagsRole).toInt();
if (flags & RefTreeModel::Shadowed)
{
option->state &= ~QStyle::State_Enabled;
}
}
};
Then I set this delegate when creating my view:
treeView = new QTreeView(this);
treeView->setModel(sceneHandler->refModel());
treeView->setItemDelegate(new SceneObjectsDelegate(this));
This is not working, and I checked initStyleOption is never called.
I'm 100% sure that a similar code has worked by the past. What can I do
wrong?
Thanks!
Etienne
_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest