PDA

View Full Version : calling paintEvent() of the super class



Cruz
15th January 2009, 17:41
Hi!

So I have overridden paintEvent() of a QFrame and I can paint what I want, but now I can do ONLY what I want. Things like background color, borders and corners are missing. Don't I have to somehow call super.paintEvent() first? How do I do that?

Thanks
Cruz

spirit
15th January 2009, 18:06
did you try something like this?


void MyFrame::paintEvent(QPaintEvent *event)
{
QFrame::paintEvent(event);
//then you can draw what you need
....
}

SimoneQt
24th March 2021, 20:29
Hi!

So I have overridden paintEvent() of a QFrame and I can paint what I want, but now I can do ONLY what I want. Things like background color, borders and corners are missing. Don't I have to somehow call super.paintEvent() first? How do I do that?

Thanks
Cruz

You have to draw the primitive element and then you draw what you want.

QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);