Results 1 to 8 of 8

Thread: QGraphicsItem - ignore parent scaling - allow local scaling

  1. #1
    Join Date
    Jul 2018
    Posts
    7
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default QGraphicsItem - ignore parent scaling - allow local scaling

    I have QGraphicsItem that is a bubble with text in it. I need to be able to flip and translate the bubble but I don't want it to scale with the view. This way it is always the same size and readable. Any help would be appreciated.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,107
    Thanks
    290
    Thanked 844 Times in 831 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QGraphicsItem - ignore parent scaling - allow local scaling

    Setting the QGraphicsItem::ItemIgnoresTransformations flag on the text bubble item should do it.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Jul 2018
    Posts
    7
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QGraphicsItem - ignore parent scaling - allow local scaling

    The problem with that is the view is inverted and flipped. So my text is backwards and upside down. That fixes the size issue but not the flip/reverse issue.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,107
    Thanks
    290
    Thanked 844 Times in 831 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QGraphicsItem - ignore parent scaling - allow local scaling

    You should be able to apply a transform to the text bubble item itself to flip / mirror it. Remember that item transformations are local to the coordinates system of the item itself. I don't remember where the origin of the text item is - upper left corner maybe, so you'll need to translate then rotate about x and y and translate back.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  5. #5
    Join Date
    Jul 2018
    Posts
    7
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QGraphicsItem - ignore parent scaling - allow local scaling

    In the paint event of my QGraphicsItem (text bubble) I can translate and flip the bubble, however, the bubble becomes oddly shaped when the parent view is scaled. Is there a way to ignore the parents scale or undo the scale in paint event?

  6. #6
    Join Date
    Jul 2018
    Posts
    7
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QGraphicsItem - ignore parent scaling - allow local scaling

    If I use the ignore transforms flag on the text bubble item, it also ignores my flip/translate in the paint event.

  7. #7
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,107
    Thanks
    290
    Thanked 844 Times in 831 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QGraphicsItem - ignore parent scaling - allow local scaling

    If I use the ignore transforms flag on the text bubble item, it also ignores my flip/translate in the paint event.
    Are you setting the transform on the QPainter during the paint event? The ignore transforms flag should only prevent transformations on the -parent- object from being propagated to the -child- that has the flag set. If you look at the documentation, it specifically mentions the case you are talking about - keeping text in the same orientation regardless of what happens to the parent item.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  8. The following user says thank you to d_stranz for this useful post:

    WolfByte (12th November 2021)

  9. #8
    Join Date
    Jul 2018
    Posts
    7
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QGraphicsItem - ignore parent scaling - allow local scaling

    You are correct. I found the mistake in my code. I was still flipping the text based on the view. After setting the Ignore flag I don't need to flip it because the transform to invert it in the first place never happened. Thank you. Sometimes it takes talking to someone else to find the simple bugs.

  10. The following user says thank you to WolfByte for this useful post:

    d_stranz (12th November 2021)

Similar Threads

  1. Do not move QGraphicsItem after scaling
    By nilot in forum Qt Programming
    Replies: 2
    Last Post: 28th September 2016, 09:19
  2. Replies: 2
    Last Post: 25th March 2011, 09:18
  3. QGraphicsItem scaling behaviour?
    By kachofool in forum Qt Programming
    Replies: 2
    Last Post: 1st January 2011, 18:17
  4. Inhibiting child scaling from parent
    By sfpiano in forum Qt Programming
    Replies: 2
    Last Post: 11th September 2010, 01:33
  5. Scaling Painter without scaling the coordinate sytem
    By maverick_pol in forum Qt Programming
    Replies: 4
    Last Post: 7th January 2008, 21:30

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.