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
    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?

  2. #2
    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, 03:11
  2. get qgraphicsitem size
    By rogerholmes in forum Newbie
    Replies: 10
    Last Post: 18th February 2010, 05:04
  3. Scale size of QGraphicsItem without scaling pen width
    By Lodorot in forum Qt Programming
    Replies: 1
    Last Post: 25th May 2009, 00:18
  4. Font size calculation when painting in a QImage
    By Ishark in forum Qt Programming
    Replies: 3
    Last Post: 15th July 2007, 22:22
  5. Force the painting of a QGraphicsItem
    By fabietto in forum Qt Programming
    Replies: 3
    Last Post: 2nd July 2007, 21: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.