What is the way to draw QStyleOptionButton QStyle::CE_CheckBox background?



  • im trying to get the parent background and set it as the checkbox background color i have this paint method that drows the checkbox :

    @void paint(QPainter *painter, const QStyleOptionViewItem &option,
    const QModelIndex &index) const
    {
    //Get item data
    bool value = index.data(Qt::UserRole).toBool();
    QString text = index.data(Qt::DisplayRole).toString();

        // fill style options with item data
        const QStyle *style = QApplication::style();
        QStyleOptionButton opt;
        opt.state |= value ? QStyle::State_On : QStyle::State_Off;
        opt.state |= QStyle::State_Enabled;
        opt.text = text;
        opt.rect = option.rect;
    

    }
    @

    but how do i set the background color of this checkbox?

        // draw item data as CheckBox
        style->drawControl(QStyle::CE_CheckBox,&opt,painter);
    }

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.