habe schon Stunden bei google verbracht aber bin noch nicht zu einer Lösung gekommen.
Ich habe eine Tabelle die in einer Spalte eine Checkbox permanent darstellen soll. Ich verwende einen Delegator dafür und habe in dem Delegator die paint() Methode überschrieben um die Checkbox dauerhaft zu zeichnen. Das sieht in etwa so aus :
Code: Alles auswählen
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
if (spalte == PRUEFLISTE_Ok ||
spalte == PRUEFLISTE_NichtOk ||
spalte == PRUEFLISTE_Instandgesetzt)
{
QStyleOptionButton newopt;
newopt.rect = opt.rect;
newopt.palette = opt.palette;
newopt.palette.setColor(QPalette::ButtonText, QColor(Qt::black));
if (spalte == PRUEFLISTE_Ok && ppt->hatStatus(PPT_InOrdnung) ||
spalte == PRUEFLISTE_NichtOk && ppt->hatStatus(PPT_NichtInOrdnung) ||
spalte == PRUEFLISTE_Instandgesetzt && ppt->hatStatus(PPT_InstandsetzungDurchgefuehrt))
{
newopt.state |= QStyle::State_On;
}
else
{
newopt.state |= QStyle::State_Off;
}
//QApplication::style()->drawControl(QStyle::CE_CheckBox, &newopt, painter);
QItemDelegate::paint(painter, option, index);
}
else
QItemDelegate::paint(painter, option, index);
Hat jemand einen Tipp ?
Vielen Dank im Vorraus
Grüße
paddy