Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    QFrame paintEvent() and StyleSheet

    General and Desktop
    1
    2
    3946
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      Morris 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)!

      1 Reply Last reply Reply Quote 0
      • M
        Morris last edited by

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

        1 Reply Last reply Reply Quote 0
        • First post
          Last post