QPalette::ColorGroup cg = option.state & QStyle::State_Enabled? QPalette::Normal : QPalette::Disabled; if( cg == QPalette::Normal && !( option.state & QStyle::State_Active ) ) cg = QPalette::Inactive;
C++ (Qt)void RemoteButton::paintEvent( QPaintEvent *event ){ QStyleOptionButton option; option.initFrom( this ); option.state |= isDown() ? QStyle::State_Sunken : QStyle::State_Raised; QPainter painter( this ); style()->drawControl( QStyle::CE_PushButtonBevel, &option, &painter, this ); ...
C++ (Qt)void TPEICombo::paintEvent(QPaintEvent* event) { QStyleOptionComboBox option; option.initFrom(this); QPainter painter(this); painter.save(); style()->drawComplexControl(QStyle::CC_ComboBox, &option, &painter, this ); painter.restore(); ... ...}
C++ (Qt)void TPEICombo::paintEvent(QPaintEvent* event) { QStylePainter painter(this); painter.setPen(palette().color(QPalette::Text)); /* draw the combobox frame, focusrect and selected etc. */ QStyleOptionComboBox opt; initStyleOption(&opt); painter.drawComplexControl(QStyle::CC_ComboBox, opt); /* draw the icon and text */ // ORIGINAL CODE //painter.drawControl(QStyle::CE_ComboBoxLabel, opt); QRect editRect = style()->subControlRect(QStyle::CC_ComboBox, &opt, QStyle::SC_ComboBoxEditField, this); // PAINTING IN editRect !!! ... ...}