QFrame paintEvent() and StyleSheet



  • 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)!



  • Ok, I find it out myself. Qt uses QWidgetPrivate to draw the background.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.