paintEvent method problem
Hi,
The code below draws the push button but not draws the focus rect with the desired color..Is there something wrong?
Code:
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 }
Re: paintEvent method problem
Still no ideas?
By the way if I do the following, it drows the border rect...
Code:
pen.setStyle(Qt::SolidLine);
pen.setColor(Qt::red);
painter.setPen(pen);
QRectF recta
= style
()->subElementRect
(QStyle::SE_PushButtonFocusRect,
&option,
this);
painter.drawRect(recta);