Results 1 to 8 of 8

Thread: QGraphicsItem::scale() bug or not ?

  1. #1
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default QGraphicsItem::scale() bug or not ?

    Hi,
    After some googling around I found a way to mirror items along X as well as Y axis. It was very simple infact,
    Qt Code:
    1. item->scale(-1.0,1.0); //mirror along y axis
    2. item->scale(1.0,-1.0); //mirror along y axis
    To copy to clipboard, switch view to plain text mode 

    That worked fine except that the item left junk when mirrored , especially when the item was not symmetric about origin. Adding an update() before the scale solved the problem. I'm using qt 4.3 on kubuntu.

    Is this a qt bug for sure ? (safe to double confirm )
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  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: QGraphicsItem::scale() bug or not ?

    What does the bounding rect of the item look like?

  3. #3
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsItem::scale() bug or not ?

    Here goes the screenshot ! The grayed item is mirrored inappropriately!

    EDIT: BTW I'm using Qt4.2.3 not Qt 4.3. I'm sorry.
    Attached Images Attached Images
    Last edited by Gopala Krishna; 14th May 2007 at 14:24. Reason: updated contents
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  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: QGraphicsItem::scale() bug or not ?

    You didn't answer my question, but I already see the problem is indeed in the bounding rect. It's not symmetric, so when you mirror, only the new bounding rect is being redrawn and it doesn't contain parts of the "old" position. It might be called a bug, but I wouldn't count on fixing it. A solution might be to invalidate and redraw the part of the scene that causes the problem or use QTransform instead of a negative scale

  5. #5
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsItem::scale() bug or not ?

    Quote Originally Posted by wysota View Post
    You didn't answer my question, but I already see the problem is indeed in the bounding rect.
    I thought the screenshot was what you asked for. I'm drawing a rect with boundingRect() dim when selected. Well the horizontal axis is along the node (red circle). You asked how does the bounding rect look like right ?

    It's not symmetric, so when you mirror, only the new bounding rect is being redrawn and it doesn't contain parts of the "old" position. It might be called a bug, but I wouldn't count on fixing it. A solution might be to invalidate and redraw the part of the scene that causes the problem or use QTransform instead of a negative scale
    Thanks for explaining me in detail. But shouldn't Item::setMatrix method do an update() and then reflect the change ? (I haven't yet checked qt code , so correct me if i'm wrong)
    And as for QTransform is concerned, my app should be compatible with Qt 4.2
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  6. #6
    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: QGraphicsItem::scale() bug or not ?

    Yes, but it updates the new bouningRect.

  7. #7
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsItem::scale() bug or not ?

    Ok thanks, I got it
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  8. #8
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsItem::scale() bug or not ?

    Quote Originally Posted by wysota View Post
    A solution might be to invalidate and redraw the part of the scene that causes the problem or use QTransform instead of a negative scale
    I couldn't find anything related to mirroring in QTRansform. Can somebody give me a hint ?
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

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.