Results 1 to 3 of 3

Thread: QGraphicsScene selectedItems bounding rect returns -nan

  1. #1
    Join Date
    Sep 2011
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows

    Default QGraphicsScene selectedItems bounding rect returns -nan

    Qt Code:
    1. QList<QGraphicsItem*> iList;
    2.  
    3. iList = scene->selectedItems();
    4. QRectF bRect = scene->selectionArea().boundingRect();
    To copy to clipboard, switch view to plain text mode 

    Hello: The above code returns
    h (qreal)
    w (qreal)
    x -nan(0xffffe1518ee2)
    y (qreal)

    Since I am new to QT perhaps this is to be expected, but the selectedItems() function seems a bit sketchy. I have an important routine that relies on it and it doesn't seem to return all the items consistently. Has anyone an explanation or similar experiences?

  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: QGraphicsScene selectedItems bounding rect returns -nan

    If selectionArea() returns an invalid path then its bounding rect will also be invalid. Did you call setSelectionArea() prior to executing this call?
    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.


  3. #3
    Join Date
    Sep 2011
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsScene selectedItems bounding rect returns -nan

    I did not call setSelection area. Trying that does give a good bounding rect. I used the rubberband selection mode using the mouse and thought that would do the job alone. but in my quick trial based on your help I took the path of the rubberband selected area and set that as the path then called setselectionarea. My way seems redundant. Is there a more elegant way to do this? Thank you for responding.

Similar Threads

  1. QGraphicsItemGroup bounding rect problem
    By jonks in forum Qt Programming
    Replies: 2
    Last Post: 28th October 2010, 05:02
  2. Replies: 0
    Last Post: 1st July 2010, 19:17
  3. Replies: 1
    Last Post: 19th December 2009, 16:46
  4. hide bounding rect
    By dreamer in forum Qt Programming
    Replies: 1
    Last Post: 8th May 2008, 10:40
  5. Image format without bounding rect
    By dreamer in forum Qt Programming
    Replies: 5
    Last Post: 30th April 2008, 23:25

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.