Results 1 to 2 of 2

Thread: How to exclude an item from scene::itemsboundingrect() call ?

  1. #1
    Join Date
    Jul 2010
    Posts
    37
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default How to exclude an item from scene::itemsboundingrect() call ?

    I want to exclude a single item from the computation of itemsboundingrect method: is this possibile? Maybe setting some flags?

    This is my motivation: I have a qgraphicsscene with few items, the scene is zoomable, and the user is able to call fitInView with a button.
    When I call fitInView, I'm using qgraphicsscene::itemsboundingrect instead of scene::scenerect(): I have no performance issues (there are too few items on the scene).
    The item I want to exlude from computation is a ruler that is longer than the other items boundingrect, and it's causing a boundingrect bigger than the necessary.

    thank you

  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: How to exclude an item from scene::itemsboundingrect() call ?

    Compute the rectangle manually.

    Qt Code:
    1. QRectF rect;
    2. foreach(QGraphicsItem *item, scene->items()){
    3. if(exclude(item)) continue;
    4. rect += item->sceneBoundingRect();
    5. }
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QGraphicsView/Scene/Item Questions
    By SixDegrees in forum Qt Programming
    Replies: 0
    Last Post: 25th August 2010, 23:41
  2. Graphics item movement and scene bounds
    By Gianluca Magnani in forum Qt Programming
    Replies: 2
    Last Post: 24th November 2009, 09:02
  3. Adding item to scene
    By lni in forum Qt Programming
    Replies: 0
    Last Post: 21st April 2009, 17:28
  4. View, Scene, Item and thread??
    By dungsivn in forum Qt Programming
    Replies: 5
    Last Post: 20th August 2008, 19:21
  5. how to zoom out item in View/Scene
    By nileshsince1980 in forum Qt Programming
    Replies: 7
    Last Post: 28th December 2007, 10:24

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.