PDA

View Full Version : How to distinguish paint events



naruto_9w
17th January 2009, 14:50
Hi all,

When i override the paintEvent of QWebView which inherts QWidget, i found that the paintEvent was consecutively called twice before the widget is shown on screen.
So my question is how to distinguish these two events, anybody help? Thanks!

Btw, i found the first event drawing the background, while the second rendering DOM elements of the webpage, using the same paintEvent.

wysota
17th January 2009, 16:27
Why would you want to distinguish those paint events?

naruto_9w
17th January 2009, 17:21
Why would you want to distinguish those paint events?

I wanna get the DOM painting and call *setMask* method in the second paint event to create a web view with transparent background on screen.

The story is told in this thread (http://www.qtcentre.org/forum/f-qt-programming-2/t-qwebview-transparent-problem-18037.html). Thanks!

wysota
17th January 2009, 21:18
Don't do that. PaintEvent is for painting and painting only. If you need to do anything else, do it elsewhere (in showEvent() maybe?).

naruto_9w
18th January 2009, 04:50
Don't do that. PaintEvent is for painting and painting only. If you need to do anything else, do it elsewhere (in showEvent() maybe?).

I know that is a not elegant way, but how to catch the exact painting contents of webpage if do not hack the paint event, showEvent is invoked before these two paint event, and *frame->render(...)* is called in paintEvent, but during my step-by-step debugging, i tried in vain to find the reason why paintEvent are called twice from the call stack, any hints for that? Thanks.

wysota
18th January 2009, 10:46
I know that is a not elegant way, but how to catch the exact painting contents of webpage if do not hack the paint event
By calling QWidget::render().

Uwe
18th January 2009, 11:27
I didn't read everything carefully, but isn't handling QEvent::PolishRequest the intended way to initialize your content.

Uwe