This problem is fixed with Qt6.10, maybe also with 6.9 but don't know exactly since there are a lot of changes in the windows11 style as it is not yet finished. This works fine for me with git HEAD:
class Delegate : public QStyledItemDelegate
{
public:
using QStyledItemDelegate::QStyledItemDelegate;
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
QStyleOptionButton buttonOption;
buttonOption.rect = option.rect;
buttonOption.palette = option.palette;
buttonOption.direction = option.direction;
buttonOption.fontMetrics = option.fontMetrics;
buttonOption.styleObject = option.styleObject;
buttonOption.state = QStyle::State_None;
buttonOption.state |= index.column() % 2 == 0 ? QStyle::State_On : QStyle::State_Off;
if (index.column() < 2)
buttonOption.state |= QStyle::State_Enabled;
option.widget->style()->drawControl(QStyle::CE_CheckBox, &buttonOption, painter, option.widget);
}
};
[image: 89ce1e26-8ddc-4464-b58e-72c1c19ca304.png]