QFrame paintEvent() and StyleSheet
-
wrote on 28 Oct 2010, 13:53 last edited by
I'm trying to understand how the QStyleSheetStyle works for QFrame.
I create a class call TestFrame
@
class TestFrame : public QFrame
{
Q_OBJECT
public:
explicit TestFrame( QWidget* parent = 0 )
{
setFrameShape(QFrame::StyledPanel);
}
protected:
void paintEvent(QPaintEvent * e)
{
QFrame::paintEvent(e);
}
};@
I apply a stylesheet to the application.
@TestFrame{
background: url(:/TestBG.png);
}@If I compile this code and run it, I can get the result shown in the First Pic.
If I comment out the line "QFrame::paintEvent(e);", then I get the result shown in the Second Pic.
I check the implementation both of QStyleSheetStyle and QFrame, and find out that QFrame::paintEvent() only deal with the border(QFrame::StyledPanel things)My question is how does QFrame manager to draw its background (specified in the CSS) outside the paintEvent()?
!http://i960.photobucket.com/albums/ae82/liangmorr/QQ.jpg?t=1288274101(Result Image)!
-
wrote on 28 Oct 2010, 14:41 last edited by
Ok, I find it out myself. Qt uses QWidgetPrivate to draw the background.
1/2