Important: Please read the Qt Code of Conduct -

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 =;
    QString text =;

        // 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

Log in to reply