Results 1 to 8 of 8

Thread: paintEvent() timing

  1. #1
    Join Date
    Sep 2015
    Posts
    7
    Thanks
    2

    Default paintEvent() timing

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: paintEvent() timing

    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,
    _

  3. #3
    Join Date
    Sep 2015
    Posts
    7
    Thanks
    2

    Default Re: paintEvent() timing

    Quote Originally Posted by anda_skoa View Post
    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.

    Quote Originally Posted by anda_skoa View Post
    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

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: paintEvent() timing

    Quote Originally Posted by dextermagnific View Post
    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?

    Quote Originally Posted by dextermagnific View Post
    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,
    _

  5. #5
    Join Date
    Sep 2015
    Posts
    7
    Thanks
    2

    Default Re: paintEvent() timing

    Quote Originally Posted by anda_skoa View Post
    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.

    Quote Originally Posted by anda_skoa View Post
    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).

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: paintEvent() timing

    Quote Originally Posted by dextermagnific View Post
    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?

    Quote Originally Posted by dextermagnific View Post
    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,
    _

  7. The following user says thank you to anda_skoa for this useful post:

    dextermagnific (18th September 2015)

  8. #7
    Join Date
    Sep 2015
    Posts
    7
    Thanks
    2

    Default Re: paintEvent() timing

    Quote Originally Posted by anda_skoa View Post
    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.

    Quote Originally Posted by anda_skoa View Post
    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

  9. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: paintEvent() timing

    Quote Originally Posted by dextermagnific View Post
    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.

    Quote Originally Posted by dextermagnific View Post
    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,
    _

Similar Threads

  1. Tool Tip Visibility Timing
    By Goug in forum Qt Programming
    Replies: 1
    Last Post: 19th January 2012, 01:50
  2. Timing in QProcess output
    By homerun4711 in forum Newbie
    Replies: 0
    Last Post: 20th December 2010, 19:37
  3. Timing for games. Is there anything like SDL_GetTicks
    By ricardo in forum Qt Programming
    Replies: 1
    Last Post: 8th August 2009, 11:24
  4. Timing out a QFtp ConnectToHost
    By skp in forum Qt Programming
    Replies: 10
    Last Post: 27th April 2008, 14:10
  5. Timer not timing out?
    By Mariane in forum Newbie
    Replies: 5
    Last Post: 2nd March 2006, 22:30

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.