Hi,
The code below draws the push button but not draws the focus rect with the desired color..Is there something wrong?
102 void CustomizedButton::paintEvent(...)
103 {
105 buttonOptions.init(this);
107 buttonOptions.rect = rect();
108 buttonOptions.palette = palette();
109 buttonOptions.
state = (isDown
() ?
QStyle::State_Sunken : QStyle::State_Raised);
110 style
()->drawPrimitive
(QStyle::PE_PanelButtonBevel,
&buttonOptions, p,
this);
111
112
113
114
115
117 frectOptions.init(this);
118 frectOptions.
palette.
setColor(QPalette::Window, Qt
::red);
119 frectOptions.
rect = style
()->subElementRect
(QStyle::SE_PushButtonFocusRect,
&buttonOptions,
this);
120 if (hasFocus())
121 style
()->drawPrimitive
(QStyle::PE_FrameFocusRect,
&frectOptions, p,
this);
122 }
102 void CustomizedButton::paintEvent(...)
103 {
104 QStyleOptionButton buttonOptions;
105 buttonOptions.init(this);
106 buttonOptions.features = QStyleOptionButton::None;
107 buttonOptions.rect = rect();
108 buttonOptions.palette = palette();
109 buttonOptions.state = (isDown() ? QStyle::State_Sunken : QStyle::State_Raised);
110 style()->drawPrimitive(QStyle::PE_PanelButtonBevel, &buttonOptions, p, this);
111
112
113
114
115
116 QStyleOptionFocusRect frectOptions;
117 frectOptions.init(this);
118 frectOptions.palette.setColor(QPalette::Window, Qt::red);
119 frectOptions.rect = style()->subElementRect(QStyle::SE_PushButtonFocusRect, &buttonOptions, this);
120 if (hasFocus())
121 style()->drawPrimitive(QStyle::PE_FrameFocusRect, &frectOptions, p, this);
122 }
To copy to clipboard, switch view to plain text mode
Bookmarks