QStyleOptionButton Farbe für QStyle::State_MouseOver ändern

Alles rund um die Programmierung mit Qt
Antworten
B4chi
Beiträge: 13
Registriert: 14. April 2009 07:58

QStyleOptionButton Farbe für QStyle::State_MouseOver ändern

Beitrag von B4chi »

Hallo,

die Überschrift sagt ja schon alles. Wo kann ich die Farbe ändern? In der Palette von QApplication? Da finde ich aber nichts für diese Role.
Danke

Code: Alles auswählen

void ItemDelegate::drawButton(QPainter *painter,
                                              const QStyleOptionViewItem& option,
                                              int y, int w, int h,
                                              const QString& value) const
{	
     const int btnW = 90;
     const int btnH = 30;
     int btnX = w - btnW - 10;
     int btnY = (h - btnH)/2;

     QStyle *style = QApplication::style();

     QStyleOptionButton opt;
     opt.text = value;
     opt.rect = QRect(btnX, btnY, btnW, btnH);
     opt.state = QStyle::State_Enabled | QStyle::State_Selected | QStyle::State_MouseOver;

     style->drawControl(QStyle::CE_PushButton, &opt, painter);
}
Antworten