Results 1 to 4 of 4

Thread: how to make the QGraphicsScene resize automaticly

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: how to make the QGraphicsScene resize automaticly

    who can give me some advice to make the QGraphicsScene resize automaticly whenever the item enlarge or shrink?
    By default scene will grow when items are added or moved, by will not shrink when items are removed or moved. Scene should be explicitly shrinked using code like this.
    Qt Code:
    1. //Calculates and returns the bounding rect of all items on the scene.
    2. //This function works by iterating over all items, and because if this, it can be slow for large scenes.
    3. QRectF rect = scene.itemsBoundingRect();
    4. scene.setSceneRect(rect);
    To copy to clipboard, switch view to plain text mode 

    Put this code in a slot connected to QGraphicsScene::changed() signal. That should appear as automatic.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

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

    aliks-os (2nd November 2016)

Similar Threads

  1. Replies: 0
    Last Post: 8th June 2012, 13:27
  2. Replies: 1
    Last Post: 24th March 2011, 04:29
  3. How to resize a QGraphicsScene to a QGraphicsView?
    By CassioTC in forum Qt Programming
    Replies: 2
    Last Post: 22nd March 2011, 09:03
  4. QGraphicsScene / QGraphicsView speed after resize
    By themolecule in forum Qt Programming
    Replies: 1
    Last Post: 21st July 2007, 23:46
  5. How can I make size of QGraphicsScene smaller?
    By troorl_ua in forum Qt Programming
    Replies: 6
    Last Post: 21st April 2007, 07:56

Tags for this Thread

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.