Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFrame paintEvent() and StyleSheet
Forum Updated to NodeBB v4.3 + New Features

QFrame paintEvent() and StyleSheet

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 4.1k Views 1 Watching
  • 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 Offline
    M Offline
    Morris
    wrote on last edited by
    #1

    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
    0
    • M Offline
      M Offline
      Morris
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved