Results 1 to 2 of 2

Thread: Where to apply transform? iterm or QPainter?

  1. #1
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Where to apply transform? iterm or QPainter?

    Hi,

    I need to plot a curve within a rectangle, the min/max of curve data will be mapped to the edge of the rectangle. In doing so, I create a QTransform, which is

    QTransform xf;
    xf.scale( rect_width / ( curveMax - curveMin ), 1 ); // assuming no scaling in Y
    xf.translate( -curveMax, 0 ); // assuming no translation in Y, but really, should I scale first, or translate first?

    After creating the transform, where do I need to set it to? The QPainter inside paint() method or the GraphicsCurveItem itself?

    I first set it to QPainter, and then change to set it to GraphicsCurveItem. In theory, they should not be any difference as the curve has no children. However, one of them caused GraphicsCurveItem's parent's sibling to be drawn in a wrong place (it appears to draw the scene more than once too), but if I resize the view, it redraws the things in the right place...

    Any idea? Thanks

  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: Where to apply transform? iterm or QPainter?

    The item should always draw itself the same way regardless of what the actual output will look like, so based on that it's safe to assume you should apply the transformation on the item. Scale the item so that it fits the rectangle you want and then move it into position.

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.