PDA

View Full Version : paintEvent() timing



dextermagnific
17th September 2015, 10:31
Hi all,

I'm the author of QSvgStyle (https://github.com/DexterMagnific/QSvgStyle) and I'd like to implement timing analysis of paint events.
I can grab the paint event by installing an event filter on the widget which is being painted by my engine to start a timer, but I'm having problems
determining when the paint event has finished processing.

Is there a way to know when an event has just finished so I can make a time diff ?

Thanks

anda_skoa
17th September 2015, 11:14
You could create a subclass of that widget and reimplement paintEvent() such that it starts the timer, calls the base class and then reads the timer.

Alternatively you could try installing a global event filter that starts the timer when it sees the paintEvent for the target and reads the timer on whatever event comes next.

Cheers,
_

dextermagnific
17th September 2015, 16:33
You could create a subclass of that widget and reimplement paintEvent() such that it starts the timer, calls the base class and then reads the timer.


That is not possible: I implement a style engine and I don't have control on apps that use it.



Alternatively you could try installing a global event filter that starts the timer when it sees the paintEvent for the target and reads the timer on whatever event comes next.

Cheers,
_

May be a good idea :) I hope that the 'next' event will come immediately after the paint event, otherwise the timing will be imprecise.

Thanks

anda_skoa
17th September 2015, 17:27
That is not possible: I implement a style engine and I don't have control on apps that use it.

Well, you can test with all common widgets and how likely are custom widgets going to call into the style?



May be a good idea :) I hope that the 'next' event will come immediately after the paint event, otherwise the timing will be imprecise.

You mean if there is not pending event?

Cheers,
_

dextermagnific
18th September 2015, 08:51
Well, you can test with all common widgets and how likely are custom widgets going to call into the style?

Yes I can do that. But the idea is that my engine supports themes. Themes can be made by users and the aim is to help the theme maker to evaluate its theme performances: for example when drawing large frames with custom SVG complex background, or when resizing the whole window. It can be a hint for him to tell if he should for example remove gradients.



You mean if there is not pending event?


I don't know if widgets constantly receive events. My concern was if the paint event was the last one (for example nothing happens on the UI for a long time).

anda_skoa
18th September 2015, 10:47
Yes I can do that. But the idea is that my engine supports themes. Themes can be made by users and the aim is to help the theme maker to evaluate its theme performances: for example when drawing large frames with custom SVG complex background, or when resizing the whole window. It can be a hint for him to tell if he should for example remove gradients.

Wouldn't it make then especially sense to have a "gallery" application that has all the standard elements?
Not just for timing but also for checking how the look?



I don't know if widgets constantly receive events. My concern was if the paint event was the last one (for example nothing happens on the UI for a long time).
You can always register a custom event and send it to yourself, so even if there is no other event in the queue the event loop will have something to process.

Cheers,
_

dextermagnific
18th September 2015, 10:57
Wouldn't it make then especially sense to have a "gallery" application that has all the standard elements?
Not just for timing but also for checking how the look?


That's what I did. I have a QSvgThemeBuilder app that shows live previews of themes. I wanted to add timing information.



You can always register a custom event and send it to yourself, so even if there is no other event in the queue the event loop will have something to process.


GREAT ! So I can 1) install an event filter on the paint event, 2) grab the time at that moment and 3) postEvent() a custom "finish paint" event. 4) diff time when the finish paint event arrives.

Will try. Thanks a lot for the help :)

anda_skoa
18th September 2015, 12:57
That's what I did. I have a QSvgThemeBuilder app that shows live previews of themes. I wanted to add timing information.

Then it is likely the best place to put the timing gathering.



GREAT ! So I can 1) install an event filter on the paint event, 2) grab the time at that moment and 3) postEvent() a custom "finish paint" event. 4) diff time when the finish paint event arrives.
Yes. Obviously not as accurate as timing the paintEvent() calls since there could be many events and their handling in between.

Cheers,
_