Results 1 to 7 of 7

Thread: Anybody knows a trick to cancel QGraphics painting ?

  1. #1
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Anybody knows a trick to cancel QGraphics painting ?

    I'd want to have (I need it... ) a method to cancel QGraphics view update - painting.
    I dont find anything. Maybe I can be possible to do it using some qapplication cancel events ?
    In addition, the drawitems is marked as obsolete (Is there some hidden substitute ? )
    Any idea ? Thanks

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Anybody knows a trick to cancel QGraphics painting ?

    Can you explain in what situation you need such thing ?

  3. #3
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Anybody knows a trick to cancel QGraphics painting ?

    Situations.... A lot, all of them when working with big vectorial worlds and big raster images.
    Basically during the painting process I see what I'm going to see and I decide to do a new zoom, or pan or close the viewer.
    (And I'm sure I can think on more ).
    Thanks.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Anybody knows a trick to cancel QGraphics painting ?

    You know, tonnot, the more questions you ask, the more it sounds like you are going about designing your application completely the wrong way.

    If you have to resort to all sorts of "outside the box" tricks to prevent Qt from doing what it was designed to do, then maybe you should question why your design seems to *require* all these tricks in order to have adequate performance. I gave you one piece of advice on how to avoid excessive repaints; you didn't like that idea, so you're still trying to find ways to defeat Qt.

    Why? You'll likely end up with an application that completely breaks next time a new release of Qt comes out or if you have to change it to add some new feature, because you've had to write it in a way that doesn't conform to standard Qt expectations.

  5. #5
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Anybody knows a trick to cancel QGraphics painting ?

    Thanks D_stranz. I thank your advice about excesive repaints. It works. But I keep having a problem when zooming. I can catch up to 5 wheel events in 100 ms. and I can draw my world into a world coordinate system resulting of the 5th zoom. But I think that the user are going to experiment some kind of disconfort. (I experiment it).
    The solution would be to draw '10 ms pieces' of my world. This would be more visually confortable. But to do this I'd need a way to cancel. Now I can only think to do something at item->paint level or calling sucesive 'invalidate_scene'.
    I'm going to think on it ... again ....
    Thanks

  6. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Anybody knows a trick to cancel QGraphics painting ?

    But I keep having a problem when zooming. I can catch up to 5 wheel events in 100 ms.
    OK, the way I handle this kind of problem is to uncouple the wheel event from zooming. Instead of zooming when the wheel event occurs, set a timer instead that has a medium-short timeout (maybe 250 - 500 ms). If the user spins the wheel quickly, a new wheel event will occur before the timer fires, so in the wheel event you record the wheel movement, stop the timer if it is running, then start it again. Finally, when the user stops moving the wheel, the timer will fire, and *then* you zoom (in the timeout slot), using the total amount of wheel movement you have added up.

    If there is 250 ms delay between the time the user stops the wheel and the update, it will not be noticeable to the user, since the redraw takes longer than that.

  7. #7
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Anybody knows a trick to cancel QGraphics painting ?

    Thanks d_stranz
    When I finished my code I have the intention to share it here . Before doing it, can I send you to know your opinion ?
    ( I promise you that the code will be fully functional, that is, it does not going to be an ask).

Similar Threads

  1. Replies: 7
    Last Post: 29th August 2011, 23:37
  2. Replies: 1
    Last Post: 24th March 2011, 14:38
  3. Stupid Windows Compilation Trick
    By skepticalgeek in forum Qt Programming
    Replies: 19
    Last Post: 14th September 2010, 17:39
  4. QString Trick please
    By baray98 in forum Qt Programming
    Replies: 1
    Last Post: 24th May 2008, 00:58
  5. Replies: 4
    Last Post: 7th March 2007, 09:45

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.