Results 1 to 8 of 8

Thread: [SOLVED] Painting QGraphicsItem constant size

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 334 Times in 317 Posts

    Default Re: Painting QGraphicsItem constant size

    How about using QGraphicsItem::setFlags(QGraphicsItem::ItemIgnoresTransformations)

  2. The following user says thank you to aamer4yu for this useful post:

    JovianGhost (20th March 2010)

  3. #2
    Join Date
    Mar 2010
    Posts
    55
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    9

    Default Re: Painting QGraphicsItem constant size

    That's PERFECT, thank you!

  4. #3
    Join Date
    Mar 2010
    Posts
    55
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    9

    Default Re: Painting QGraphicsItem constant size

    Ach, I take that back, it's not perfect!

    After making this change, when I zoom in, the scrollbars don't appear as they did before! How do I fix this?

  5. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Wiki edits
    5

    Default Re: Painting QGraphicsItem constant size

    did you update your scene rect after zooming?

  6. #5
    Join Date
    Mar 2010
    Posts
    55
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    9

    Default Re: Painting QGraphicsItem constant size

    Quote Originally Posted by Lykurg View Post
    did you update your scene rect after zooming?
    Yep, that did the trick, thanks! I thought QGraphicsView would do it for me, but I suppose that flag I set prevents that from happening.


    In case anyone stumbles on this thread in the future, here's what I did: after setting the proper scale in the zoom function, I added

    Qt Code:
    1. // Update the scene's bounds
    2. QRectF rect = scene()->itemsBoundingRect();
    3. if (rect.isNull())
    4. scene()->setSceneRect(QRectF(0, 0, 1, 1));
    5. else
    6. scene()->setSceneRect(rect);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 7
    Last Post: 21st March 2010, 04:11
  2. get qgraphicsitem size
    By rogerholmes in forum Newbie
    Replies: 10
    Last Post: 18th February 2010, 06:04
  3. Scale size of QGraphicsItem without scaling pen width
    By Lodorot in forum Qt Programming
    Replies: 1
    Last Post: 25th May 2009, 01:18
  4. Font size calculation when painting in a QImage
    By Ishark in forum Qt Programming
    Replies: 3
    Last Post: 15th July 2007, 23:22
  5. Force the painting of a QGraphicsItem
    By fabietto in forum Qt Programming
    Replies: 3
    Last Post: 2nd July 2007, 22:28

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
  •  
Qt is a trademark of The Qt Company.