Results 1 to 4 of 4

Thread: QPainter bounds question

  1. #1
    Join Date
    Jun 2007
    Posts
    56
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default QPainter bounds question

    Lets suppose that in my custom repaint method, I create a painter and set a window size of, say ( -5000, -5000, 10000, 10000) and start to draw various points in to the window. Is there any way to query the painter for a bounding rectangle for only the points that I draw?

    I would like to know because it would make scaling easier. IOW, I can scale such that all of my data points are contained in the viewport.

    I get the feeling that I am going to have to keep track of it myself as I am painting and then scale it, but I wonder if the painter has such a capability.

    Mic.

  2. #2
    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: QPainter bounds question

    I'm not exactly sure what you want, but you can query the widget's size by using QWidget::contentsRect() or the painter size (both logical and physical) by using QPainter::window() and QPainter::viewport().

  3. #3
    Join Date
    Jun 2007
    Posts
    56
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QPainter bounds question

    What I need is a quick way to set the scale such that all of the data points are contained within the viewport. I was hoping that the painter would keep track of something like that so that it could be quickly retrieved.

  4. #4
    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: QPainter bounds question

    In my opinion all you need is to draw the data points using logical coordinates and set the range of those coordinates as the painter's window using QPainter::setWindow().

Similar Threads

  1. QPainter, setWindow, setViewport question
    By Micawber in forum Qt Programming
    Replies: 4
    Last Post: 3rd September 2007, 18:33
  2. Question on QPainter setWindow use
    By impeteperry in forum Qt Programming
    Replies: 14
    Last Post: 8th August 2006, 13:26
  3. Replies: 7
    Last Post: 20th March 2006, 20:03

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.