Results 1 to 3 of 3

Thread: Question regarding how to paint after zoom.

  1. #1
    Join Date
    Jan 2007
    Posts
    81
    Thanks
    17
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Question regarding how to paint after zoom.

    Hello all, I am using QT4.2 for the first time and I am currently writing a program that can zoom in and out of "background widget". "background widget" is set as the primary widget for a scroll area so when zoomed in you can still scroll around.

    My question is as follows: should I be using update() or repaint() to call paintEvent within "background widget" after the zoomin calculation is done?

    In this example repaint() is used: http://qt4.digitalfanatics.org/articles/zoomer.html
    but on the trolltech website they always use update() in their examples and in the qwidget documentation it recommends to use update unless it's animation.

    I have tried to use update() but the following error happens: when I use my rubberband to zoom....the contents within the rubberband are the colour of where the rubberband was started......I update the rubberband dimensions in the mouse events.
    When using repaint() this doesn't happen....and I am confused why this makes a difference?


    My second question is...I want to make a crosshairs over the entire viewport area to show an updating scale for each time you zoom in. I have tried to put this into paintevent of "background widget", but there are problems when scrolling using the scrollbars(the transparent crosshairs don't get wiped over....but stay creating a smear effect). Should I be writing this somewhere else?

    Any help would be much appreciated, thank you!!!

    Jonathan

  2. #2
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Question regarding how to paint after zoom.

    I wrote the article you refer to. If Trolltech says update, do use update.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Question regarding how to paint after zoom.

    update() schedules a paintEvent (in short uses postEvent) whereas repaint() repaints instantly (in short uses sendEvent). You should always use update() unless you have a good reason to use repaint().

Similar Threads

  1. QThread exit()/quit() question
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 28th August 2006, 15:38
  2. Paint MainWindow Regions
    By pedros09 in forum Qt Programming
    Replies: 1
    Last Post: 5th May 2006, 10:43
  3. paint QTreeView item !!
    By mcenatie in forum Qt Programming
    Replies: 2
    Last Post: 19th March 2006, 15:24
  4. Zoom Options
    By Kapil in forum Qt Programming
    Replies: 2
    Last Post: 9th March 2006, 12:19
  5. Question about QImages
    By SkripT in forum Qt Programming
    Replies: 14
    Last Post: 27th January 2006, 12: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.