[Qt-interest] QGraphicsScene: get bounding box of selected items?
Malyushytsky, Alex
alex at wai.com
Mon Dec 27 23:35:30 CET 2010
>> Off course I can iterate over all rects
AFAIK that what you should do.
If you have to do it often you could add cashing:
For example:
- add to your QGraphicsScene derived class
member to store bounding box of selection QRectF,
initialize it to invalid rectangle when selection is changed.
- add function which would return this value if it is valid, first computing it only (as you already do) if it is not.
Use this function when you need to get selection bounding rectangle.
It might be possible that some private implementation of QGraphicsScene already has such value cashed, but I would not rely on the private implementation, not counting that it is not normally accessible.
Alex
-----Original Message-----
From: qt-interest-bounces+alex=wai.com at qt.nokia.com [mailto:qt-interest-bounces+alex=wai.com at qt.nokia.com] On Behalf Of Oliver.Knoll at comit.ch
Sent: Monday, December 27, 2010 1:38 AM
To: qt-interest at trolltech.com
Subject: [Qt-interest] QGraphicsScene: get bounding box of selected items?
Hi,
I am getting familiar with the QGraphicsScene API. Is there a method to get the bounding box of the selected items?
This exists: http://doc.qt.nokia.com/latest/qgraphicsscene.html#itemsBoundingRect
which gives me the bounding rect of /all/ items - is there an analogon/convenience method for getting the bounding rect of the /selected/ items only?
The purpose is that I want to render only the selected items into an image.
Off course I can iterate over all rects as returned by
http://doc.qt.nokia.com/latest/qgraphicsscene.html#selectedItems
and call http://doc.qt.nokia.com/latest/qrectf.html#united on their http://doc.qt.nokia.com/latest/qgraphicsitem.html#boundingRect, but I wonder whether I overlooked some convenience method somewhere in the Qt API...
Cheers, Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22
_______________________________________________
Qt-interest mailing list
Qt-interest at qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-interest
---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.
“This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you.”
“Please consider our environment before printing this email.”
More information about the Qt-interest-old
mailing list