@andi456 Just in case someone has a similar problem. The solution for me was indeed the hint given in the link above.
As can be seen from the posted paint method above, I use a function to determine the rectangle of the checkBox, which looks like this
QRect CheckBoxZBuchDeckDelegate::getCheckBoxRect(const QStyleOptionViewItem &option) const {
QStyleOptionViewItem opt = option;
auto widget = opt.widget;
auto style = widget->style();
auto checkboxSize = style->subElementRect(QStyle::SE_CheckBoxIndicator, &option, widget).size();
return QStyle::alignedRect(option.direction, Qt::AlignCenter, checkboxSize, option.rect);
}
So I just used the same function in the eventEditor method copied from the qt-sources of qstyleditemdelegate.cpp
after deleting the lines containing
const QWidget *widget = QStyledItemDelegatePrivate::widget(option);
QStyle *style = widget ? widget->style() : QApplication::style();
I replaced
QRect checkRect = style->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &viewOpt, widget);
with
QRect checkRect = this->getCheckBoxRect(option);
et voilà.
If a QStyledItemDelegate should answer to an event, the area to be clicked has to be announced to the editorEvent too.