Results 1 to 5 of 5

Thread: Stop repaint while scrolling in paintEvent()

  1. #1
    Join Date
    Jul 2010
    Posts
    33
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Stop repaint while scrolling in paintEvent()

    Hi,

    I have draw thousand of lines using paintEvent(). When I scroll or minimize the widget the paintEvent call again and again start drawing the same drawn line again and again. How can I stop to call paintEvent when we scrolling or minimize. I want that we draw a line once then there is no need to draw the same line again and again while minimize or scroll.

    Thanks & Regards
    Sagir Ahmed

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Stop repaint while scrolling in paintEvent()

    Quote Originally Posted by sagirahmed View Post
    Hi,

    I have draw thousand of lines using paintEvent(). When I scroll or minimize the widget the paintEvent call again and again start drawing the same drawn line again and again.
    Be sure not to loop the paint event. This means, do not call the paint event from within the paint event, do not update the widget in any way inside the paint event.

    Use a trigger timer. Set it to, for example, 50ms. Inside that time, the paintEvent will just return. Outside that interval, the paint event will be executed and the trigger timer restarted. Of course, that will lead to uglyness. At least paint some parts of the widget, but maybe not its calculation heavy contents.

    How can I stop to call paintEvent when we scrolling or minimize.
    See above.

    I want that we draw a line once then there is no need to draw the same line again and again while minimize or scroll.
    Use a buffer.

  3. #3
    Join Date
    Jul 2010
    Posts
    33
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Stop repaint while scrolling in paintEvent()

    Hi,

    Actully paintEvent call automatically when I minimize or do some event on Widget. I want to stop the calling of paintEvent again and again Once I have drawn the line.

  4. #4
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Stop repaint while scrolling in paintEvent()

    Quote Originally Posted by sagirahmed View Post
    Hi,

    Actully paintEvent call automatically when I minimize or do some event on Widget.
    Yes, I know, but that is not what I meant. This is normal and should not be changed.

    I want to stop the calling of paintEvent again and again Once I have drawn the line.
    Like I said above, use a buffer, an image if you will, and instead of drawing lines, you draw the image.

    Or, and this is not very easy if you're a beginner, use QtConcurrent to draw the contents in a picture. Then use a future watcher to paint the finished picture. Let the future update when the widget changed.

  5. #5
    Join Date
    Jul 2010
    Posts
    33
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Stop repaint while scrolling in paintEvent()

    Hi,

    Is this possible to create the image(QImage or QPixmap) that i have drawn using paintEvent(), If i will able to create the image that I have drawn then this image will be easily set to any QLabel with scrolling.

Similar Threads

  1. Replies: 4
    Last Post: 17th October 2010, 22:30
  2. Replies: 4
    Last Post: 10th June 2010, 21:25
  3. qtextbrowser stop scrolling on append
    By tpf80 in forum Qt Programming
    Replies: 2
    Last Post: 16th September 2007, 20:28
  4. Stop the thread
    By santosh.kumar in forum Qt Programming
    Replies: 1
    Last Post: 14th May 2007, 10:29
  5. repaint help pls
    By munna in forum Qt Programming
    Replies: 3
    Last Post: 21st June 2006, 10:52

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.