QTreeWidgetItem Disable | Enable
Unsolved
General and Desktop
-
@VRonin said in QTreeWidgetItem Disable | Enable:
What's the difference between an enabled and disabled item? just the colour of the text? Does the behaviour change between the two?
No.
If I'm turned on or off, I'll have to decide on the following steps. -
Then you are misusing
setDisabled
.- set the a boolean in the
Qt::UserRole
(true when is disabled)if(last->data(Qt::UserRole).toBool()) last->setData(Qt::UserRole,QVariant()); else last->setData(Qt::UserRole,true);
- reimplement
QStyledItemDelegate::paint
to use it.- starting from the original source: https://code.woboq.org/qt5/qtbase/src/widgets/itemviews/qstyleditemdelegate.cpp.html#_ZNK19QStyledItemDelegate5paintEP8QPainterRK20QStyleOptionViewItemRK11QModelIndex
- replace
QStyledItemDelegatePrivate::widget(option);
withoption.widget;
- add
if(index.data(Qt::UserRole).toBool()) option.state &= ~QStyle::State_Enabled;
in the line belowinitStyleOption
- apply the delegate to the view
- in the constructor call
ui->treeWidget->setItemDelegate(new MyDelegate(this));
- in the constructor call
- set the a boolean in the