Qyoto
4.0.5
Qyoto is a C# language binding for Qt
|
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items. More...
Public Types | |
enum | ItemIndexMethod { BspTreeIndex = 0, NoIndex = -1 } |
More... | |
enum | SceneLayer { AllLayers = 65535, BackgroundLayer = 2, ForegroundLayer = 4, ItemLayer = 1 } |
More... | |
Public Member Functions | |
QGraphicsScene (QObject parent=null) | |
| |
QGraphicsScene (QRectF sceneRect, QObject parent=null) | |
| |
QGraphicsScene (double x, double y, double width, double height, QObject parent=null) | |
| |
override void | CreateProxy () |
new QGraphicsEllipseItem | AddEllipse (QRectF rect) |
| |
new QGraphicsEllipseItem | AddEllipse (QRectF rect, QPen pen) |
| |
new QGraphicsEllipseItem | AddEllipse (QRectF rect, QPen pen, QBrush brush) |
| |
new QGraphicsEllipseItem | AddEllipse (double x, double y, double w, double h) |
| |
new QGraphicsEllipseItem | AddEllipse (double x, double y, double w, double h, QPen pen) |
| |
new QGraphicsEllipseItem | AddEllipse (double x, double y, double w, double h, QPen pen, QBrush brush) |
| |
new void | AddItem (IQGraphicsItem item) |
| |
new QGraphicsLineItem | AddLine (QLineF line) |
| |
new QGraphicsLineItem | AddLine (QLineF line, QPen pen) |
| |
new QGraphicsLineItem | AddLine (double x1, double y1, double x2, double y2) |
| |
new QGraphicsLineItem | AddLine (double x1, double y1, double x2, double y2, QPen pen) |
| |
new QGraphicsPathItem | AddPath (QPainterPath path) |
| |
new QGraphicsPathItem | AddPath (QPainterPath path, QPen pen) |
| |
new QGraphicsPathItem | AddPath (QPainterPath path, QPen pen, QBrush brush) |
| |
new QGraphicsPixmapItem | AddPixmap (QPixmap pixmap) |
| |
new QGraphicsPolygonItem | AddPolygon (QPolygonF polygon) |
| |
new QGraphicsPolygonItem | AddPolygon (QPolygonF polygon, QPen pen) |
| |
new QGraphicsPolygonItem | AddPolygon (QPolygonF polygon, QPen pen, QBrush brush) |
| |
new QGraphicsRectItem | AddRect (QRectF rect) |
| |
new QGraphicsRectItem | AddRect (QRectF rect, QPen pen) |
| |
new QGraphicsRectItem | AddRect (QRectF rect, QPen pen, QBrush brush) |
| |
new QGraphicsRectItem | AddRect (double x, double y, double w, double h) |
| |
new QGraphicsRectItem | AddRect (double x, double y, double w, double h, QPen pen) |
| |
new QGraphicsRectItem | AddRect (double x, double y, double w, double h, QPen pen, QBrush brush) |
| |
new QGraphicsSimpleTextItem | AddSimpleText (string text) |
| |
new QGraphicsSimpleTextItem | AddSimpleText (string text, QFont font) |
| |
new QGraphicsTextItem | AddText (string text) |
| |
new QGraphicsTextItem | AddText (string text, QFont font) |
| |
new QGraphicsProxyWidget | AddWidget (QWidget widget, Qt.WindowType wFlags=0) |
| |
new void | Advance () |
| |
new void | Clear () |
| |
new void | ClearFocus () |
| |
new void | ClearSelection () |
| |
new System.Collections.Generic.List < IQGraphicsItem > | CollidingItems (IQGraphicsItem item, Qt.ItemSelectionMode mode=Qt.ItemSelectionMode.IntersectsItemShape) |
| |
new QGraphicsItemGroup | CreateItemGroup (System.Collections.Generic.List< IQGraphicsItem > items) |
| |
new void | DestroyItemGroup (QGraphicsItemGroup group) |
| |
override bool | OnEvent (QEvent @event) |
| |
override bool | EventFilter (QObject watched, QEvent @event) |
| |
new bool | HasFocus () |
| |
new double | Height () |
| |
virtual object | InputMethodQuery (Qt.InputMethodQuery query) |
| |
new void | Invalidate () |
| |
new void | Invalidate (QRectF rect, QGraphicsScene.SceneLayer layers=QGraphicsScene.SceneLayer.AllLayers) |
| |
new void | Invalidate (double x, double y, double w, double h, QGraphicsScene.SceneLayer layers=QGraphicsScene.SceneLayer.AllLayers) |
| |
new bool | IsActive () |
| |
new IQGraphicsItem | ItemAt (QPointF pos) |
| |
new IQGraphicsItem | ItemAt (QPointF pos, QTransform deviceTransform) |
| |
new IQGraphicsItem | ItemAt (double x, double y) |
| |
new IQGraphicsItem | ItemAt (double x, double y, QTransform deviceTransform) |
| |
new System.Collections.Generic.List < IQGraphicsItem > | Items () |
| |
new System.Collections.Generic.List < IQGraphicsItem > | Items (QPointF pos) |
| |
new System.Collections.Generic.List < IQGraphicsItem > | Items (QRectF rect, Qt.ItemSelectionMode mode=Qt.ItemSelectionMode.IntersectsItemShape) |
| |
new System.Collections.Generic.List < IQGraphicsItem > | Items (QPolygonF polygon, Qt.ItemSelectionMode mode=Qt.ItemSelectionMode.IntersectsItemShape) |
| |
new System.Collections.Generic.List < IQGraphicsItem > | Items (QPainterPath path, Qt.ItemSelectionMode mode=Qt.ItemSelectionMode.IntersectsItemShape) |
| |
new System.Collections.Generic.List < IQGraphicsItem > | Items (QPointF pos, Qt.ItemSelectionMode mode, Qt.SortOrder order) |
| |
new System.Collections.Generic.List < IQGraphicsItem > | Items (QRectF rect, Qt.ItemSelectionMode mode, Qt.SortOrder order) |
| |
new System.Collections.Generic.List < IQGraphicsItem > | Items (QPolygonF polygon, Qt.ItemSelectionMode mode, Qt.SortOrder order) |
| |
new System.Collections.Generic.List < IQGraphicsItem > | Items (QPainterPath path, Qt.ItemSelectionMode mode, Qt.SortOrder order) |
| |
new System.Collections.Generic.List < IQGraphicsItem > | Items (QPointF pos, Qt.ItemSelectionMode mode, Qt.SortOrder order, QTransform deviceTransform) |
| |
new System.Collections.Generic.List < IQGraphicsItem > | Items (QRectF rect, Qt.ItemSelectionMode mode, Qt.SortOrder order, QTransform deviceTransform) |
| |
new System.Collections.Generic.List < IQGraphicsItem > | Items (QPolygonF polygon, Qt.ItemSelectionMode mode, Qt.SortOrder order, QTransform deviceTransform) |
| |
new System.Collections.Generic.List < IQGraphicsItem > | Items (QPainterPath path, Qt.ItemSelectionMode mode, Qt.SortOrder order, QTransform deviceTransform) |
| |
new System.Collections.Generic.List < IQGraphicsItem > | Items (Qt.SortOrder order) |
| |
new System.Collections.Generic.List < IQGraphicsItem > | Items (double x, double y, double w, double h, Qt.ItemSelectionMode mode=Qt.ItemSelectionMode.IntersectsItemShape) |
| |
new System.Collections.Generic.List < IQGraphicsItem > | Items (double x, double y, double w, double h, Qt.ItemSelectionMode mode, Qt.SortOrder order) |
| |
new System.Collections.Generic.List < IQGraphicsItem > | Items (double x, double y, double w, double h, Qt.ItemSelectionMode mode, Qt.SortOrder order, QTransform deviceTransform) |
| |
new QRectF | ItemsBoundingRect () |
| |
new IQGraphicsItem | MouseGrabberItem () |
| |
new void | RemoveItem (IQGraphicsItem item) |
| |
new void | Render (QPainter painter) |
| |
new void | Render (QPainter painter, QRectF target) |
| |
new void | Render (QPainter painter, QRectF target, QRectF source, Qt.AspectRatioMode aspectRatioMode=Qt.AspectRatioMode.KeepAspectRatio) |
| |
new System.Collections.Generic.List < IQGraphicsItem > | SelectedItems () |
| |
new bool | OnSendEvent (IQGraphicsItem item, QEvent @event) |
| |
new void | SetFocus (Qt.FocusReason focusReason=Qt.FocusReason.OtherFocusReason) |
| |
new void | SetFocusItem (IQGraphicsItem item, Qt.FocusReason focusReason=Qt.FocusReason.OtherFocusReason) |
| |
new void | SetSceneRect (double x, double y, double w, double h) |
new void | SetSelectionArea (QPainterPath path, QTransform deviceTransform) |
| |
new void | SetSelectionArea (QPainterPath path, Qt.ItemSelectionMode mode) |
| |
new void | SetSelectionArea (QPainterPath path, Qt.ItemSelectionMode mode, QTransform deviceTransform) |
| |
new void | Update () |
| |
new void | Update (QRectF rect) |
| |
new void | Update (double x, double y, double w, double h) |
| |
new System.Collections.Generic.List < QGraphicsView > | Views () |
| |
new double | Width () |
| |
new void | Dispose () |
Public Member Functions inherited from QtCore.QObject | |
QObject (QObject parent=null) | |
| |
new bool | BlockSignals (bool b) |
| |
new System.Collections.Generic.List < QObject > | Children () |
| |
new bool | Connect (QObject sender, string signal, string member, Qt.ConnectionType type=Qt.ConnectionType.AutoConnection) |
| |
new void | DeleteLater () |
| |
new bool | Disconnect (QObject receiver, string member=null) |
| |
new bool | Disconnect (string signal=null, QObject receiver=null, string member=null) |
| |
new void | DumpObjectInfo () |
| |
new void | DumpObjectTree () |
| |
new System.Collections.Generic.List < QByteArray > | DynamicPropertyNames () |
| |
virtual bool | OnEvent (QEvent arg1) |
| |
virtual bool | EventFilter (QObject arg1, QEvent arg2) |
| |
new bool | Inherits (string classname) |
| |
new void | InstallEventFilter (QObject arg1) |
| |
new bool | IsWidgetType () |
| |
new void | KillTimer (int id) |
| |
new object | Property (string name) |
| |
new void | RemoveEventFilter (QObject arg1) |
| |
new bool | SetProperty (string name, object value) |
| |
new void | SetUserData (uint id, QObjectUserData data) |
new bool | SignalsBlocked () |
| |
new int | StartTimer (int interval) |
| |
new QObjectUserData | UserData (uint id) |
new void | Dispose () |
Public Member Functions inherited from QtCore.Qt | |
delegate QTextStream | FuncQTextStreamQTextStream (QTextStream qTextStream) |
delegate string | FuncStringQByteArray (QByteArray qByteArray) |
delegate QByteArray | FuncQByteArrayString (string @string) |
delegate void | ActionQtMsgTypeString (QtMsgType qtMsgType, string @string) |
delegate QObject | FuncQObject () |
Static Public Member Functions | |
static string | Tr (string s, string c=null) |
static string | Tr (string s, string c, int n) |
static string | TrUtf8 (string s, string c=null) |
static string | TrUtf8 (string s, string c, int n) |
Static Public Member Functions inherited from QtCore.QObject | |
static bool | Connect (QObject sender, QMetaMethod signal, QObject receiver, QMetaMethod method, Qt.ConnectionType type=Qt.ConnectionType.AutoConnection) |
| |
static bool | Connect (QObject sender, string signal, QObject receiver, string member, Qt.ConnectionType arg5=Qt.ConnectionType.AutoConnection) |
| |
static bool | Disconnect (QObject sender, QMetaMethod signal, QObject receiver, QMetaMethod member) |
| |
static bool | Disconnect (QObject sender, string signal, QObject receiver, string member) |
| |
static uint | RegisterUserData () |
static string | Tr (string s, string c=null) |
| |
static string | Tr (string s, string c, int n) |
| |
static string | TrUtf8 (string s, string c=null) |
| |
static string | TrUtf8 (string s, string c, int n) |
| |
Static Public Member Functions inherited from QtCore.Qt | |
static QDataStream | Write (QDataStream s, object p) |
static QDataStream | Write (QDataStream arg1, QSizeF arg2) |
static QTextStream | Write (QTextStream s, Qt.FuncQTextStreamQTextStream f) |
static QDataStream | Write (QDataStream arg1, QPoint arg2) |
static QDataStream | Write (QDataStream arg1, QLineF arg2) |
static QDataStream | Write (QDataStream arg1, QPointF arg2) |
static QDataStream | Write (QDataStream arg1, QChar arg2) |
static QDataStream | Write (QDataStream arg1, QByteArray arg2) |
static QDataStream | Write (QDataStream arg1, QEasingCurve arg2) |
static QDataStream | Write (QDataStream arg1, QRectF arg2) |
static QDataStream | Write (QDataStream arg1, QDateTime arg2) |
static QDataStream | Write (QDataStream arg1, QUrl arg2) |
static QDataStream | Write (QDataStream arg1, QTime arg2) |
static QDataStream | Write (QDataStream arg1, QLocale arg2) |
static QDataStream | Write (QDataStream arg1, QBitArray arg2) |
static QDataStream | Write (QDataStream arg1, QUuid arg2) |
static QDataStream | Write (QDataStream arg1, QLine arg2) |
static QDataStream | Write (QDataStream arg1, QDate arg2) |
static QDataStream | Write (QDataStream @out, QRegExp regExp) |
static QDataStream | Write (QDataStream arg1, QRect arg2) |
static QDataStream | Write (QDataStream arg1, QSize arg2) |
static QDataStream | Write (QDataStream s, QVariant.Type p) |
static QDataStream | Write (QDataStream arg1, string arg2) |
static QDataStream | Write (QDataStream @out, System.Collections.Generic.List< string > list) |
static QDataStream | Read (QDataStream arg1, QChar arg2) |
static QDataStream | Read (QDataStream arg1, QLocale arg2) |
static QDataStream | Read (QDataStream arg1, QRect arg2) |
static QDataStream | Read (QDataStream arg1, QEasingCurve arg2) |
static QDataStream | Read (QDataStream arg1, QDate arg2) |
static QDataStream | Read (QDataStream arg1, QUrl arg2) |
static QDataStream | Read (QDataStream arg1, QUuid arg2) |
static QTextStream | Read (QTextStream s, Qt.FuncQTextStreamQTextStream f) |
static QDataStream | Read (QDataStream arg1, QLineF arg2) |
static QDataStream | Read (QDataStream arg1, QRectF arg2) |
static QDataStream | Read (QDataStream arg1, QPointF arg2) |
static QDataStream | Read (QDataStream arg1, QLine arg2) |
static QDataStream | Read (QDataStream arg1, QBitArray arg2) |
static QDataStream | Read (QDataStream arg1, QSize arg2) |
static QDataStream | Read (QDataStream arg1, QDateTime arg2) |
static QDataStream | Read (QDataStream arg1, QTime arg2) |
static QDataStream | Read (QDataStream arg1, QPoint arg2) |
static QDataStream | Read (QDataStream @in, QRegExp regExp) |
static QDataStream | Read (QDataStream s, object p) |
static QDataStream | Read (QDataStream arg1, QByteArray arg2) |
static QDataStream | Read (QDataStream arg1, QSizeF arg2) |
static QDataStream | Read (QDataStream arg1, string arg2) |
static QDataStream | Read (QDataStream s, QVariant.Type p) |
static QDataStream | Read (QDataStream @in, System.Collections.Generic.List< string > list) |
static double | qAcos (double v) |
static void | qAddPostRoutine (System.Action arg1) |
static string | qAppName () |
static double | qAsin (double v) |
static double | qAtan (double v) |
static double | qAtan2 (double x, double y) |
static void | qBadAlloc () |
static int | qCeil (double v) |
static ushort | qChecksum (string s, uint len) |
static QByteArray | qCompress (QByteArray data) |
static QByteArray | qCompress (QByteArray data, int compressionLevel=-1) |
static QByteArray | qCompress (Pointer< byte > data, int nbytes) |
static QByteArray | qCompress (Pointer< byte > data, int nbytes, int compressionLevel=-1) |
static double | qCos (double v) |
static double | qExp (double v) |
static double | qFabs (double v) |
static double | qFastCos (double x) |
static double | qFastSin (double x) |
static string | qFlagLocation (string method) |
static int | qFloor (double v) |
static bool | qFuzzyCompare (double p1, double p2) |
static bool | qFuzzyCompare (float p1, float p2) |
static bool | qFuzzyIsNull (double d) |
static bool | qFuzzyIsNull (float f) |
static uint | qHash (QBitArray key) |
static uint | qHash (QChar key) |
static uint | qHash (QStringRef key) |
static uint | qHash (QUrl url) |
static uint | qHash (QPersistentModelIndex index) |
static uint | qHash (QByteArray key) |
static uint | qHash (QModelIndex index) |
static uint | qHash (uint key) |
static uint | qHash (sbyte key) |
static uint | qHash (byte key) |
static uint | qHash (short key) |
static uint | qHash (NativeLong key) |
static uint | qHash (ushort key) |
static uint | qHash (long key) |
static uint | qHash (ulong key) |
static uint | qHash (int key) |
static uint | qHash (string key) |
static uint | qHash (NativeULong key) |
static double | qInf () |
static Qt.ActionQtMsgTypeString | qInstallMsgHandler (Qt.ActionQtMsgTypeString arg1) |
static int | qIntCast (float f) |
static int | qIntCast (double f) |
static bool | qIsFinite (double d) |
static bool | qIsFinite (float f) |
static bool | qIsInf (float f) |
static bool | qIsInf (double d) |
static bool | qIsNaN (float f) |
static bool | qIsNaN (double d) |
static bool | qIsNull (float f) |
static bool | qIsNull (double d) |
static double | qLn (double v) |
static double | qPow (double x, double y) |
static double | qQNaN () |
static void | qRegisterStaticPluginInstanceFunction (Qt.FuncQObject function) |
static void | qRemovePostRoutine (System.Action arg1) |
static int | qRound (double d) |
static long | qRound64 (double d) |
static double | qSNaN () |
static bool | qSharedBuild () |
static double | qSin (double v) |
static double | qSqrt (double v) |
static bool | qStringComparisonHelper (QStringRef s1, string s2) |
static double | qTan (double v) |
static QByteArray | qUncompress (QByteArray data) |
static QByteArray | qUncompress (Pointer< byte > data, int nbytes) |
static string | qVersion () |
static void | Qbswap_helper (Pointer< byte > src, Pointer< byte > dest, int size) |
static QByteArray | Qgetenv (string varName) |
static bool | Qputenv (string varName, QByteArray value) |
static int | Qrand () |
static void | Qsrand (uint seed) |
static int | Qstrcmp (QByteArray str1, QByteArray str2) |
static int | Qstrcmp (QByteArray str1, string str2) |
static int | Qstrcmp (string str1, QByteArray str2) |
static int | Qstrcmp (string str1, string str2) |
static Pointer< sbyte > | Qstrcpy (Pointer< sbyte > dst, string src) |
static Pointer< sbyte > | Qstrdup (string arg1) |
static int | Qstricmp (string arg1, string arg2) |
static uint | Qstrlen (string str) |
static int | Qstrncmp (string str1, string str2, uint len) |
static Pointer< sbyte > | Qstrncpy (Pointer< sbyte > dst, string src, uint len) |
static int | Qstrnicmp (string arg1, string arg2, uint len) |
static uint | Qstrnlen (string str, uint maxlen) |
static string | QtTrId (string id, int n=-1) |
Properties | |
Slot < System.Collections.Generic.List < QRectF > > | Changed |
| |
Slot< QRectF > | SceneRectChanged |
| |
Slot | SelectionChanged |
| |
new IQGraphicsItem | ActivePanel [get, set] |
| |
new QGraphicsWidget | ActiveWindow [get, set] |
| |
new QPainterPath | SelectionArea [get, set] |
| |
new QStyle | Style [get, set] |
| |
new IQGraphicsItem | FocusItem [get] |
| |
new QBrush | BackgroundBrush [get, set] |
| |
new QBrush | ForegroundBrush [get, set] |
| |
new ItemIndexMethod | itemIndexMethod [get, set] |
| |
new QRectF | SceneRect [get, set] |
| |
new int | BspTreeDepth [get, set] |
| |
new QPalette | Palette [get, set] |
| |
new QFont | Font [get, set] |
| |
new bool | SortCacheEnabled [get, set] |
| |
new bool | StickyFocus [get, set] |
| |
static new QMetaObject | StaticMetaObject [get] |
new IQGraphicsSceneSignals | Emit [get] |
Properties inherited from QtCore.QObject | |
virtual EventHandler < QEventArgs< QChildEvent > > | ChildEvent |
| |
virtual EventHandler < QEventArgs< QEvent > > | CustomEvent |
| |
virtual EventHandler < QEventArgs< QEvent > > | Event |
| |
virtual EventHandler < QEventArgs< QTimerEvent > > | TimerEvent |
| |
Slot< QObject > | DestroyedQObject |
Slot | Destroyed |
| |
new QObject | Parent [get, set] |
| |
virtual System.IntPtr | SmokeObject [get, set] |
new string | ObjectName [get, set] |
| |
static new QMetaObject | StaticMetaObject [get] |
| |
static new QMetaObject | StaticQtMetaObject [get] |
new IQObjectSignals | Emit [get] |
Additional Inherited Members | |
Protected Attributes inherited from QtCore.QObject | |
object | Q_EMIT = null |
SmokeInvocation | interceptor |
readonly List< QEventHandler > | eventFilters = new List<QEventHandler>() |
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items.
The class serves as a container for QGraphicsItems. It is used together with QGraphicsView for visualizing graphical items, such as lines, rectangles, text, or even custom items, on a 2D surface. QGraphicsScene is part of the Graphics View Framework.
QGraphicsScene also provides functionality that lets you efficiently determine both the location of items, and for determining what items are visible within an arbitrary area on the scene. With the QGraphicsView widget, you can either visualize the whole scene, or zoom in and view only parts of the scene.
Example:
QGraphicsScene scene;
scene.addText("Hello, world!");
QGraphicsView view(&scene);
view.show();
Note that QGraphicsScene has no visual appearance of its own; it only manages the items. You need to create a QGraphicsView widget to visualize the scene.
To add items to a scene, you start off by constructing a QGraphicsScene object. Then, you have two options: either add your existing QGraphicsItem objects by calling addItem(), or you can call one of the convenience functions addEllipse(), addLine(), addPath(), addPixmap(), addPolygon(), addRect(), or addText(), which all return a pointer to the newly added item. The dimensions of the items added with these functions are relative to the item's coordinate system, and the items position is initialized to (0, 0) in the scene.
You can then visualize the scene using QGraphicsView. When the scene changes, (e.g., when an item moves or is transformed) QGraphicsScene emits the changed() signal. To remove an item, call removeItem().
QGraphicsScene uses an indexing algorithm to manage the location of items efficiently. By default, a BSP (Binary Space Partitioning) tree is used; an algorithm suitable for large scenes where most items remain static (i.e., do not move around). You can choose to disable this index by calling setItemIndexMethod(). For more information about the available indexing algorithms, see the itemIndexMethod property.
The scene's bounding rect is set by calling setSceneRect(). Items can be placed at any position on the scene, and the size of the scene is by default unlimited. The scene rect is used only for internal bookkeeping, maintaining the scene's item index. If the scene rect is unset, QGraphicsScene will use the bounding area of all items, as returned by itemsBoundingRect(), as the scene rect. However, itemsBoundingRect() is a relatively time consuming function, as it operates by collecting positional information for every item on the scene. Because of this, you should always set the scene rect when operating on large scenes.
One of QGraphicsScene's greatest strengths is its ability to efficiently determine the location of items. Even with millions of items on the scene, the items() functions can determine the location of an item within few milliseconds. There are several overloads to items(): one that finds items at a certain position, one that finds items inside or intersecting with a polygon or a rectangle, and more. The list of returned items is sorted by stacking order, with the topmost item being the first item in the list. For convenience, there is also an itemAt() function that returns the topmost item at a given position.
QGraphicsScene maintains selection information for the scene. To select items, call setSelectionArea(), and to clear the current selection, call clearSelection(). Call selectedItems() to get the list of all selected items.
Event Handling and Propagation
Another responsibility that QGraphicsScene has, is to propagate events from QGraphicsView. To send an event to a scene, you construct an event that inherits QEvent, and then send it using, for example, QApplication::sendEvent(). event() is responsible for dispatching the event to the individual items. Some common events are handled by convenience event handlers. For example, key press events are handled by keyPressEvent(), and mouse press events are handled by mousePressEvent().
Key events are delivered to the focus item. To set the focus item, you can either call setFocusItem(), passing an item that accepts focus, or the item itself can call QGraphicsItem::setFocus(). Call focusItem() to get the current focus item. For compatibility with widgets, the scene also maintains its own focus information. By default, the scene does not have focus, and all key events are discarded. If setFocus() is called, or if an item on the scene gains focus, the scene automatically gains focus. If the scene has focus, hasFocus() will return true, and key events will be forwarded to the focus item, if any. If the scene loses focus, (i.e., someone calls clearFocus()) while an item has focus, the scene will maintain its item focus information, and once the scene regains focus, it will make sure the last focus item regains focus.
For mouse-over effects, QGraphicsScene dispatches hover events. If an item accepts hover events (see QGraphicsItem::acceptHoverEvents()), it will receive a GraphicsSceneHoverEnter event when the mouse enters its area. As the mouse continues moving inside the item's area, QGraphicsScene will send it GraphicsSceneHoverMove events. When the mouse leaves the item's area, the item will receive a GraphicsSceneHoverLeave event.
All mouse events are delivered to the current mouse grabber item. An item becomes the scene's mouse grabber if it accepts mouse events (see QGraphicsItem::acceptedMouseButtons()) and it receives a mouse press. It stays the mouse grabber until it receives a mouse release when no other mouse buttons are pressed. You can call mouseGrabberItem() to determine what item is currently grabbing the mouse.
See also QGraphicsItem and QGraphicsView.
This enum describes the indexing algorithms QGraphicsScene provides for managing positional information about items on the scene.
See also setItemIndexMethod() and bspTreeDepth.
BspTreeIndex |
A Binary Space Partitioning tree is applied. All QGraphicsScene's item location algorithms are of an order close to logarithmic complexity, by making use of binary search. Adding, moving and removing items is logarithmic. This approach is best for static scenes (i.e., scenes where most items do not move). |
NoIndex |
No index is applied. Item location is of linear complexity, as all items on the scene are searched. Adding, moving and removing items, however, is done in constant time. This approach is ideal for dynamic scenes, where many items are added, moved or removed continuously. |
This enum describes the rendering layers in a QGraphicsScene. When QGraphicsScene draws the scene contents, it renders each of these layers separately, in order.
Each layer represents a flag that can be OR'ed together when calling functions such as invalidate() or QGraphicsView::invalidateScene().
This enum was introduced or modified in Qt 4.3.
See also invalidate() and QGraphicsView::invalidateScene().
AllLayers |
All layers; this value represents a combination of all three layers. |
BackgroundLayer |
The background layer. QGraphicsScene renders the scene's background in this layer by calling the virtual function drawBackground(). The background layer is drawn first of all layers. |
ForegroundLayer |
The foreground layer. QGraphicsScene renders the scene's foreground in this layer by calling the virtual function drawForeground(). The foreground layer is drawn last of all layers. |
ItemLayer |
The item layer. QGraphicsScene renders all items are in this layer by calling the virtual function drawItems(). The item layer is drawn after the background layer, but before the foreground layer. |
|
protected |
QtGui.QGraphicsScene.QGraphicsScene | ( | QObject | parent = null | ) |
Constructs a QGraphicsScene object. The parent parameter is passed to QObject's constructor.
Constructs a QGraphicsScene object, using sceneRect for its scene rectangle. The parent parameter is passed to QObject's constructor.
See also sceneRect.
QtGui.QGraphicsScene.QGraphicsScene | ( | double | x, |
double | y, | ||
double | width, | ||
double | height, | ||
QObject | parent = null |
||
) |
Constructs a QGraphicsScene object. The parent parameter is passed to QObject's constructor.
new QGraphicsEllipseItem QtGui.QGraphicsScene.AddEllipse | ( | QRectF | rect | ) |
Creates and adds an ellipse item to the scene, and returns the item pointer. The geometry of the ellipse is defined by rect, and its pen and brush are initialized to pen and brush.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
See also addLine(), addPath(), addPixmap(), addRect(), addText(), addItem(), and addWidget().
new QGraphicsEllipseItem QtGui.QGraphicsScene.AddEllipse | ( | QRectF | rect, |
QPen | pen | ||
) |
Creates and adds an ellipse item to the scene, and returns the item pointer. The geometry of the ellipse is defined by rect, and its pen and brush are initialized to pen and brush.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
See also addLine(), addPath(), addPixmap(), addRect(), addText(), addItem(), and addWidget().
new QGraphicsEllipseItem QtGui.QGraphicsScene.AddEllipse | ( | QRectF | rect, |
QPen | pen, | ||
QBrush | brush | ||
) |
Creates and adds an ellipse item to the scene, and returns the item pointer. The geometry of the ellipse is defined by rect, and its pen and brush are initialized to pen and brush.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
See also addLine(), addPath(), addPixmap(), addRect(), addText(), addItem(), and addWidget().
new QGraphicsEllipseItem QtGui.QGraphicsScene.AddEllipse | ( | double | x, |
double | y, | ||
double | w, | ||
double | h | ||
) |
Creates and adds an ellipse item to the scene, and returns the item pointer. The geometry of the ellipse is defined by rect, and its pen and brush are initialized to pen and brush.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
See also addLine(), addPath(), addPixmap(), addRect(), addText(), addItem(), and addWidget().
new QGraphicsEllipseItem QtGui.QGraphicsScene.AddEllipse | ( | double | x, |
double | y, | ||
double | w, | ||
double | h, | ||
QPen | pen | ||
) |
Creates and adds an ellipse item to the scene, and returns the item pointer. The geometry of the ellipse is defined by rect, and its pen and brush are initialized to pen and brush.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
See also addLine(), addPath(), addPixmap(), addRect(), addText(), addItem(), and addWidget().
new QGraphicsEllipseItem QtGui.QGraphicsScene.AddEllipse | ( | double | x, |
double | y, | ||
double | w, | ||
double | h, | ||
QPen | pen, | ||
QBrush | brush | ||
) |
Creates and adds an ellipse item to the scene, and returns the item pointer. The geometry of the ellipse is defined by rect, and its pen and brush are initialized to pen and brush.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
See also addLine(), addPath(), addPixmap(), addRect(), addText(), addItem(), and addWidget().
new void QtGui.QGraphicsScene.AddItem | ( | IQGraphicsItem | item | ) |
Adds or moves the item and all its childen to this scene. This scene takes ownership of the item.
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
If the item is already in a different scene, it will first be removed from its old scene, and then added to this scene as a top-level.
QGraphicsScene will send ItemSceneChange notifications to item while it is added to the scene. If item does not currently belong to a scene, only one notification is sent. If it does belong to scene already (i.e., it is moved to this scene), QGraphicsScene will send an addition notification as the item is removed from its previous scene.
If the item is a panel, the scene is active, and there is no active panel in the scene, then the item will be activated.
See also removeItem(), addEllipse(), addLine(), addPath(), addPixmap(), addRect(), addText(), addWidget(), and Sorting.
new QGraphicsLineItem QtGui.QGraphicsScene.AddLine | ( | QLineF | line | ) |
Creates and adds a line item to the scene, and returns the item pointer. The geometry of the line is defined by line, and its pen is initialized to pen.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
See also addEllipse(), addPath(), addPixmap(), addRect(), addText(), addItem(), and addWidget().
new QGraphicsLineItem QtGui.QGraphicsScene.AddLine | ( | QLineF | line, |
QPen | pen | ||
) |
Creates and adds a line item to the scene, and returns the item pointer. The geometry of the line is defined by line, and its pen is initialized to pen.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
See also addEllipse(), addPath(), addPixmap(), addRect(), addText(), addItem(), and addWidget().
new QGraphicsLineItem QtGui.QGraphicsScene.AddLine | ( | double | x1, |
double | y1, | ||
double | x2, | ||
double | y2 | ||
) |
Creates and adds a line item to the scene, and returns the item pointer. The geometry of the line is defined by line, and its pen is initialized to pen.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
See also addEllipse(), addPath(), addPixmap(), addRect(), addText(), addItem(), and addWidget().
new QGraphicsLineItem QtGui.QGraphicsScene.AddLine | ( | double | x1, |
double | y1, | ||
double | x2, | ||
double | y2, | ||
QPen | pen | ||
) |
Creates and adds a line item to the scene, and returns the item pointer. The geometry of the line is defined by line, and its pen is initialized to pen.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
See also addEllipse(), addPath(), addPixmap(), addRect(), addText(), addItem(), and addWidget().
new QGraphicsPathItem QtGui.QGraphicsScene.AddPath | ( | QPainterPath | path | ) |
Creates and adds a path item to the scene, and returns the item pointer. The geometry of the path is defined by path, and its pen and brush are initialized to pen and brush.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
See also addEllipse(), addLine(), addPixmap(), addRect(), addText(), addItem(), and addWidget().
new QGraphicsPathItem QtGui.QGraphicsScene.AddPath | ( | QPainterPath | path, |
QPen | pen | ||
) |
Creates and adds a path item to the scene, and returns the item pointer. The geometry of the path is defined by path, and its pen and brush are initialized to pen and brush.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
See also addEllipse(), addLine(), addPixmap(), addRect(), addText(), addItem(), and addWidget().
new QGraphicsPathItem QtGui.QGraphicsScene.AddPath | ( | QPainterPath | path, |
QPen | pen, | ||
QBrush | brush | ||
) |
Creates and adds a path item to the scene, and returns the item pointer. The geometry of the path is defined by path, and its pen and brush are initialized to pen and brush.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
See also addEllipse(), addLine(), addPixmap(), addRect(), addText(), addItem(), and addWidget().
new QGraphicsPixmapItem QtGui.QGraphicsScene.AddPixmap | ( | QPixmap | pixmap | ) |
Creates and adds a pixmap item to the scene, and returns the item pointer. The pixmap is defined by pixmap.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
See also addEllipse(), addLine(), addPath(), addRect(), addText(), addItem(), and addWidget().
new QGraphicsPolygonItem QtGui.QGraphicsScene.AddPolygon | ( | QPolygonF | polygon | ) |
Creates and adds a polygon item to the scene, and returns the item pointer. The polygon is defined by polygon, and its pen and brush are initialized to pen and brush.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
See also addEllipse(), addLine(), addPath(), addRect(), addText(), addItem(), and addWidget().
new QGraphicsPolygonItem QtGui.QGraphicsScene.AddPolygon | ( | QPolygonF | polygon, |
QPen | pen | ||
) |
Creates and adds a polygon item to the scene, and returns the item pointer. The polygon is defined by polygon, and its pen and brush are initialized to pen and brush.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
See also addEllipse(), addLine(), addPath(), addRect(), addText(), addItem(), and addWidget().
new QGraphicsPolygonItem QtGui.QGraphicsScene.AddPolygon | ( | QPolygonF | polygon, |
QPen | pen, | ||
QBrush | brush | ||
) |
Creates and adds a polygon item to the scene, and returns the item pointer. The polygon is defined by polygon, and its pen and brush are initialized to pen and brush.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
See also addEllipse(), addLine(), addPath(), addRect(), addText(), addItem(), and addWidget().
new QGraphicsRectItem QtGui.QGraphicsScene.AddRect | ( | QRectF | rect | ) |
Creates and adds a rectangle item to the scene, and returns the item pointer. The geometry of the rectangle is defined by rect, and its pen and brush are initialized to pen and brush.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0). For example, if a QRect(50, 50, 100, 100) is added, its top-left corner will be at (50, 50) relative to the origin in the items coordinate system.
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
See also addEllipse(), addLine(), addPixmap(), addPixmap(), addText(), addItem(), and addWidget().
new QGraphicsRectItem QtGui.QGraphicsScene.AddRect | ( | QRectF | rect, |
QPen | pen | ||
) |
Creates and adds a rectangle item to the scene, and returns the item pointer. The geometry of the rectangle is defined by rect, and its pen and brush are initialized to pen and brush.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0). For example, if a QRect(50, 50, 100, 100) is added, its top-left corner will be at (50, 50) relative to the origin in the items coordinate system.
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
See also addEllipse(), addLine(), addPixmap(), addPixmap(), addText(), addItem(), and addWidget().
new QGraphicsRectItem QtGui.QGraphicsScene.AddRect | ( | QRectF | rect, |
QPen | pen, | ||
QBrush | brush | ||
) |
Creates and adds a rectangle item to the scene, and returns the item pointer. The geometry of the rectangle is defined by rect, and its pen and brush are initialized to pen and brush.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0). For example, if a QRect(50, 50, 100, 100) is added, its top-left corner will be at (50, 50) relative to the origin in the items coordinate system.
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
See also addEllipse(), addLine(), addPixmap(), addPixmap(), addText(), addItem(), and addWidget().
new QGraphicsRectItem QtGui.QGraphicsScene.AddRect | ( | double | x, |
double | y, | ||
double | w, | ||
double | h | ||
) |
Creates and adds a rectangle item to the scene, and returns the item pointer. The geometry of the rectangle is defined by rect, and its pen and brush are initialized to pen and brush.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0). For example, if a QRect(50, 50, 100, 100) is added, its top-left corner will be at (50, 50) relative to the origin in the items coordinate system.
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
See also addEllipse(), addLine(), addPixmap(), addPixmap(), addText(), addItem(), and addWidget().
new QGraphicsRectItem QtGui.QGraphicsScene.AddRect | ( | double | x, |
double | y, | ||
double | w, | ||
double | h, | ||
QPen | pen | ||
) |
Creates and adds a rectangle item to the scene, and returns the item pointer. The geometry of the rectangle is defined by rect, and its pen and brush are initialized to pen and brush.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0). For example, if a QRect(50, 50, 100, 100) is added, its top-left corner will be at (50, 50) relative to the origin in the items coordinate system.
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
See also addEllipse(), addLine(), addPixmap(), addPixmap(), addText(), addItem(), and addWidget().
new QGraphicsRectItem QtGui.QGraphicsScene.AddRect | ( | double | x, |
double | y, | ||
double | w, | ||
double | h, | ||
QPen | pen, | ||
QBrush | brush | ||
) |
Creates and adds a rectangle item to the scene, and returns the item pointer. The geometry of the rectangle is defined by rect, and its pen and brush are initialized to pen and brush.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0). For example, if a QRect(50, 50, 100, 100) is added, its top-left corner will be at (50, 50) relative to the origin in the items coordinate system.
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
See also addEllipse(), addLine(), addPixmap(), addPixmap(), addText(), addItem(), and addWidget().
new QGraphicsSimpleTextItem QtGui.QGraphicsScene.AddSimpleText | ( | string | text | ) |
Creates and adds a QGraphicsSimpleTextItem to the scene, and returns the item pointer. The text string is initialized to text, and its font is initialized to font.
The item's position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
See also addEllipse(), addLine(), addPixmap(), addPixmap(), addRect(), addItem(), and addWidget().
new QGraphicsSimpleTextItem QtGui.QGraphicsScene.AddSimpleText | ( | string | text, |
QFont | font | ||
) |
Creates and adds a QGraphicsSimpleTextItem to the scene, and returns the item pointer. The text string is initialized to text, and its font is initialized to font.
The item's position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
See also addEllipse(), addLine(), addPixmap(), addPixmap(), addRect(), addItem(), and addWidget().
new QGraphicsTextItem QtGui.QGraphicsScene.AddText | ( | string | text | ) |
Creates and adds a text item to the scene, and returns the item pointer. The text string is initialized to text, and its font is initialized to font.
The item's position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
See also addEllipse(), addLine(), addPixmap(), addPixmap(), addRect(), addItem(), and addWidget().
new QGraphicsTextItem QtGui.QGraphicsScene.AddText | ( | string | text, |
QFont | font | ||
) |
Creates and adds a text item to the scene, and returns the item pointer. The text string is initialized to text, and its font is initialized to font.
The item's position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
See also addEllipse(), addLine(), addPixmap(), addPixmap(), addRect(), addItem(), and addWidget().
new QGraphicsProxyWidget QtGui.QGraphicsScene.AddWidget | ( | QWidget | widget, |
Qt.WindowType | wFlags = 0 |
||
) |
Creates a new QGraphicsProxyWidget for widget, adds it to the scene, and returns a pointer to the proxy. wFlags set the default window flags for the embedding proxy widget.
The item's position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
Note that widgets with the Qt::WA_PaintOnScreen widget attribute set and widgets that wrap an external application or controller are not supported. Examples are QGLWidget and QAxWidget.
See also addEllipse(), addLine(), addPixmap(), addPixmap(), addRect(), addText(), addSimpleText(), and addItem().
new void QtGui.QGraphicsScene.Advance | ( | ) |
This slot advances the scene by one step, by calling QGraphicsItem::advance() for all items on the scene. This is done in two phases: in the first phase, all items are notified that the scene is about to change, and in the second phase all items are notified that they can move. In the first phase, QGraphicsItem::advance() is called passing a value of 0 as an argument, and 1 is passed in the second phase.
See also QGraphicsItem::advance(), QGraphicsItemAnimation, and QTimeLine.
new void QtGui.QGraphicsScene.Clear | ( | ) |
Removes and deletes all items from the scene, but otherwise leaves the state of the scene unchanged.
This function was introduced in Qt 4.4.
See also addItem().
new void QtGui.QGraphicsScene.ClearFocus | ( | ) |
Clears focus from the scene. If any item has focus when this function is called, it will lose focus, and regain focus again once the scene regains focus.
A scene that does not have focus ignores key events.
See also hasFocus(), setFocus(), and setFocusItem().
new void QtGui.QGraphicsScene.ClearSelection | ( | ) |
Clears the current selection.
See also setSelectionArea() and selectedItems().
new System.Collections.Generic.List<IQGraphicsItem> QtGui.QGraphicsScene.CollidingItems | ( | IQGraphicsItem | item, |
Qt.ItemSelectionMode | mode = Qt.ItemSelectionMode.IntersectsItemShape |
||
) |
Returns a list of all items that collide with item. Collisions are determined by calling QGraphicsItem::collidesWithItem(); the collision detection is determined by mode. By default, all items whose shape intersects item or is contained inside item's shape are returned.
The items are returned in descending stacking order (i.e., the first item in the list is the uppermost item, and the last item is the lowermost item).
See also items(), itemAt(), QGraphicsItem::collidesWithItem(), and Sorting.
new QGraphicsItemGroup QtGui.QGraphicsScene.CreateItemGroup | ( | System.Collections.Generic.List< IQGraphicsItem > | items | ) |
Groups all items in items into a new QGraphicsItemGroup, and returns a pointer to the group. The group is created with the common ancestor of items as its parent, and with position (0, 0). The items are all reparented to the group, and their positions and transformations are mapped to the group. If items is empty, this function will return an empty top-level QGraphicsItemGroup.
QGraphicsScene has ownership of the group item; you do not need to delete it. To dismantle (ungroup) a group, call destroyItemGroup().
See also destroyItemGroup() and QGraphicsItemGroup::addToGroup().
|
virtual |
Reimplemented from QtCore.QObject.
new void QtGui.QGraphicsScene.DestroyItemGroup | ( | QGraphicsItemGroup | group | ) |
Reparents all items in group to group's parent item, then removes group from the scene, and finally deletes it. The items' positions and transformations are mapped from the group to the group's parent.
See also createItemGroup() and QGraphicsItemGroup::removeFromGroup().
new void QtGui.QGraphicsScene.Dispose | ( | ) |
Draws the background of the scene using painter, before any items and the foreground are drawn. Reimplement this function to provide a custom background for the scene.
All painting is done in scene coordinates. The rect parameter is the exposed rectangle.
If all you want is to define a color, texture, or gradient for the background, you can call setBackgroundBrush() instead.
See also drawForeground() and drawItems().
Draws the foreground of the scene using painter, after the background and all items have been drawn. Reimplement this function to provide a custom foreground for the scene.
All painting is done in scene coordinates. The rect parameter is the exposed rectangle.
If all you want is to define a color, texture or gradient for the foreground, you can call setForegroundBrush() instead.
See also drawBackground() and drawItems().
|
protectedvirtual |
Paints the given items using the provided painter, after the background has been drawn, and before the foreground has been drawn. All painting is done in scene coordinates. Before drawing each item, the painter must be transformed using QGraphicsItem::sceneTransform().
The options parameter is the list of style option objects for each item in items. The numItems parameter is the number of items in items and options in options. The widget parameter is optional; if specified, it should point to the widget that is being painted on.
The default implementation prepares the painter matrix, and calls QGraphicsItem::paint() on all items. Reimplement this function to provide custom painting of all items for the scene; gaining complete control over how each item is drawn. In some cases this can increase drawing performance significantly.
Example:
void CustomScene::drawItems(QPainter *painter, int numItems,
QGraphicsItem *items[],
const QStyleOptionGraphicsItem options[],
QWidget *widget)
{
for (int i = 0; i < numItems; ++i) {
// Draw the item
painter->save();
painter->setMatrix(items[i]->sceneMatrix(), true);
items[i]->paint(painter, &options[i], widget);
painter->restore();
}
}
Since Qt 4.6, this function is not called anymore unless the QGraphicsView::IndirectPainting flag is given as an Optimization flag.
See also drawBackground() and drawForeground().
Reimplemented from QObject::eventFilter().
QGraphicsScene filters QApplication's events to detect palette and font changes.
|
protected |
Finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab, and returns true if it can find a new widget, or false if it cannot. If next is true, this function searches forward; if next is false, it searches backward.
You can reimplement this function in a subclass of QGraphicsScene to provide fine-grained control over how tab focus passes inside your scene. The default implementation is based on the tab focus chain defined by QGraphicsWidget::setTabOrder().
This function was introduced in Qt 4.4.
new bool QtGui.QGraphicsScene.HasFocus | ( | ) |
Returns true if the scene has focus; otherwise returns false. If the scene has focus, it will will forward key events from QKeyEvent to any item that has focus.
See also setFocus() and setFocusItem().
new double QtGui.QGraphicsScene.Height | ( | ) |
This convenience function is equivalent to calling sceneRect().height().
See also width().
|
virtual |
This method is used by input methods to query a set of properties of the scene to be able to support complex input method operations as support for surrounding text and reconversions.
The query parameter specifies which property is queried.
See also QWidget::inputMethodQuery().
new void QtGui.QGraphicsScene.Invalidate | ( | ) |
Invalidates and schedules a redraw of the layers in rect on the scene. Any cached content in layers is unconditionally invalidated and redrawn.
You can use this function overload to notify QGraphicsScene of changes to the background or the foreground of the scene. This function is commonly used for scenes with tile-based backgrounds to notify changes when QGraphicsView has enabled CacheBackground.
Example:
QRectF TileScene::rectForTile(int x, int y) const
{
// Return the rectangle for the tile at position (x, y).
return QRectF(x * tileWidth, y * tileHeight, tileWidth, tileHeight);
}
void TileScene::setTile(int x, int y, const QPixmap &pixmap)
{
// Sets or replaces the tile at position (x, y) with pixmap.
if (x >= 0 && x < numTilesH && y >= 0 && y < numTilesV) {
tiles[y][x] = pixmap;
invalidate(rectForTile(x, y), BackgroundLayer);
}
}
void TileScene::drawBackground(QPainter *painter, const QRectF &exposed)
{
// Draws all tiles that intersect the exposed area.
for (int y = 0; y < numTilesV; ++y) {
for (int x = 0; x < numTilesH; ++x) {
QRectF rect = rectForTile(x, y);
if (exposed.intersects(rect))
painter->drawPixmap(rect.topLeft(), tiles[y][x]);
}
}
}
Note that QGraphicsView currently supports background caching only (see QGraphicsView::CacheBackground). This function is equivalent to calling update() if any layer but BackgroundLayer is passed.
See also QGraphicsView::resetCachedContent().
new void QtGui.QGraphicsScene.Invalidate | ( | QRectF | rect, |
QGraphicsScene.SceneLayer | layers = QGraphicsScene.SceneLayer.AllLayers |
||
) |
Invalidates and schedules a redraw of the layers in rect on the scene. Any cached content in layers is unconditionally invalidated and redrawn.
You can use this function overload to notify QGraphicsScene of changes to the background or the foreground of the scene. This function is commonly used for scenes with tile-based backgrounds to notify changes when QGraphicsView has enabled CacheBackground.
Example:
QRectF TileScene::rectForTile(int x, int y) const
{
// Return the rectangle for the tile at position (x, y).
return QRectF(x * tileWidth, y * tileHeight, tileWidth, tileHeight);
}
void TileScene::setTile(int x, int y, const QPixmap &pixmap)
{
// Sets or replaces the tile at position (x, y) with pixmap.
if (x >= 0 && x < numTilesH && y >= 0 && y < numTilesV) {
tiles[y][x] = pixmap;
invalidate(rectForTile(x, y), BackgroundLayer);
}
}
void TileScene::drawBackground(QPainter *painter, const QRectF &exposed)
{
// Draws all tiles that intersect the exposed area.
for (int y = 0; y < numTilesV; ++y) {
for (int x = 0; x < numTilesH; ++x) {
QRectF rect = rectForTile(x, y);
if (exposed.intersects(rect))
painter->drawPixmap(rect.topLeft(), tiles[y][x]);
}
}
}
Note that QGraphicsView currently supports background caching only (see QGraphicsView::CacheBackground). This function is equivalent to calling update() if any layer but BackgroundLayer is passed.
See also QGraphicsView::resetCachedContent().
new void QtGui.QGraphicsScene.Invalidate | ( | double | x, |
double | y, | ||
double | w, | ||
double | h, | ||
QGraphicsScene.SceneLayer | layers = QGraphicsScene.SceneLayer.AllLayers |
||
) |
Invalidates and schedules a redraw of the layers in rect on the scene. Any cached content in layers is unconditionally invalidated and redrawn.
You can use this function overload to notify QGraphicsScene of changes to the background or the foreground of the scene. This function is commonly used for scenes with tile-based backgrounds to notify changes when QGraphicsView has enabled CacheBackground.
Example:
QRectF TileScene::rectForTile(int x, int y) const
{
// Return the rectangle for the tile at position (x, y).
return QRectF(x * tileWidth, y * tileHeight, tileWidth, tileHeight);
}
void TileScene::setTile(int x, int y, const QPixmap &pixmap)
{
// Sets or replaces the tile at position (x, y) with pixmap.
if (x >= 0 && x < numTilesH && y >= 0 && y < numTilesV) {
tiles[y][x] = pixmap;
invalidate(rectForTile(x, y), BackgroundLayer);
}
}
void TileScene::drawBackground(QPainter *painter, const QRectF &exposed)
{
// Draws all tiles that intersect the exposed area.
for (int y = 0; y < numTilesV; ++y) {
for (int x = 0; x < numTilesH; ++x) {
QRectF rect = rectForTile(x, y);
if (exposed.intersects(rect))
painter->drawPixmap(rect.topLeft(), tiles[y][x]);
}
}
}
Note that QGraphicsView currently supports background caching only (see QGraphicsView::CacheBackground). This function is equivalent to calling update() if any layer but BackgroundLayer is passed.
See also QGraphicsView::resetCachedContent().
new bool QtGui.QGraphicsScene.IsActive | ( | ) |
Returns true if the scene is active (e.g., it's viewed by at least one QGraphicsView that is active); otherwise returns false.
This function was introduced in Qt 4.6.
See also QGraphicsItem::isActive() and QWidget::isActiveWindow().
new IQGraphicsItem QtGui.QGraphicsScene.ItemAt | ( | QPointF | pos | ) |
Returns the topmost visible item at the specified position, or 0 if there are no items at this position.
deviceTransform is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.
This function was introduced in Qt 4.6.
See also items(), collidingItems(), and Sorting.
new IQGraphicsItem QtGui.QGraphicsScene.ItemAt | ( | QPointF | pos, |
QTransform | deviceTransform | ||
) |
Returns the topmost visible item at the specified position, or 0 if there are no items at this position.
deviceTransform is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.
This function was introduced in Qt 4.6.
See also items(), collidingItems(), and Sorting.
new IQGraphicsItem QtGui.QGraphicsScene.ItemAt | ( | double | x, |
double | y | ||
) |
Returns the topmost visible item at the specified position, or 0 if there are no items at this position.
deviceTransform is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.
This function was introduced in Qt 4.6.
See also items(), collidingItems(), and Sorting.
new IQGraphicsItem QtGui.QGraphicsScene.ItemAt | ( | double | x, |
double | y, | ||
QTransform | deviceTransform | ||
) |
Returns the topmost visible item at the specified position, or 0 if there are no items at this position.
deviceTransform is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.
This function was introduced in Qt 4.6.
See also items(), collidingItems(), and Sorting.
new System.Collections.Generic.List<IQGraphicsItem> QtGui.QGraphicsScene.Items | ( | ) |
Returns a list of all items in the scene in descending stacking order.
See also addItem(), removeItem(), and Sorting.
new System.Collections.Generic.List<IQGraphicsItem> QtGui.QGraphicsScene.Items | ( | QPointF | pos | ) |
Returns a list of all items in the scene in descending stacking order.
See also addItem(), removeItem(), and Sorting.
new System.Collections.Generic.List<IQGraphicsItem> QtGui.QGraphicsScene.Items | ( | QRectF | rect, |
Qt.ItemSelectionMode | mode = Qt.ItemSelectionMode.IntersectsItemShape |
||
) |
Returns a list of all items in the scene in descending stacking order.
See also addItem(), removeItem(), and Sorting.
new System.Collections.Generic.List<IQGraphicsItem> QtGui.QGraphicsScene.Items | ( | QPolygonF | polygon, |
Qt.ItemSelectionMode | mode = Qt.ItemSelectionMode.IntersectsItemShape |
||
) |
Returns a list of all items in the scene in descending stacking order.
See also addItem(), removeItem(), and Sorting.
new System.Collections.Generic.List<IQGraphicsItem> QtGui.QGraphicsScene.Items | ( | QPainterPath | path, |
Qt.ItemSelectionMode | mode = Qt.ItemSelectionMode.IntersectsItemShape |
||
) |
Returns a list of all items in the scene in descending stacking order.
See also addItem(), removeItem(), and Sorting.
new System.Collections.Generic.List<IQGraphicsItem> QtGui.QGraphicsScene.Items | ( | QPointF | pos, |
Qt.ItemSelectionMode | mode, | ||
Qt.SortOrder | order | ||
) |
Returns a list of all items in the scene in descending stacking order.
See also addItem(), removeItem(), and Sorting.
new System.Collections.Generic.List<IQGraphicsItem> QtGui.QGraphicsScene.Items | ( | QRectF | rect, |
Qt.ItemSelectionMode | mode, | ||
Qt.SortOrder | order | ||
) |
Returns a list of all items in the scene in descending stacking order.
See also addItem(), removeItem(), and Sorting.
new System.Collections.Generic.List<IQGraphicsItem> QtGui.QGraphicsScene.Items | ( | QPolygonF | polygon, |
Qt.ItemSelectionMode | mode, | ||
Qt.SortOrder | order | ||
) |
Returns a list of all items in the scene in descending stacking order.
See also addItem(), removeItem(), and Sorting.
new System.Collections.Generic.List<IQGraphicsItem> QtGui.QGraphicsScene.Items | ( | QPainterPath | path, |
Qt.ItemSelectionMode | mode, | ||
Qt.SortOrder | order | ||
) |
Returns a list of all items in the scene in descending stacking order.
See also addItem(), removeItem(), and Sorting.
new System.Collections.Generic.List<IQGraphicsItem> QtGui.QGraphicsScene.Items | ( | QPointF | pos, |
Qt.ItemSelectionMode | mode, | ||
Qt.SortOrder | order, | ||
QTransform | deviceTransform | ||
) |
Returns a list of all items in the scene in descending stacking order.
See also addItem(), removeItem(), and Sorting.
new System.Collections.Generic.List<IQGraphicsItem> QtGui.QGraphicsScene.Items | ( | QRectF | rect, |
Qt.ItemSelectionMode | mode, | ||
Qt.SortOrder | order, | ||
QTransform | deviceTransform | ||
) |
Returns a list of all items in the scene in descending stacking order.
See also addItem(), removeItem(), and Sorting.
new System.Collections.Generic.List<IQGraphicsItem> QtGui.QGraphicsScene.Items | ( | QPolygonF | polygon, |
Qt.ItemSelectionMode | mode, | ||
Qt.SortOrder | order, | ||
QTransform | deviceTransform | ||
) |
Returns a list of all items in the scene in descending stacking order.
See also addItem(), removeItem(), and Sorting.
new System.Collections.Generic.List<IQGraphicsItem> QtGui.QGraphicsScene.Items | ( | QPainterPath | path, |
Qt.ItemSelectionMode | mode, | ||
Qt.SortOrder | order, | ||
QTransform | deviceTransform | ||
) |
Returns a list of all items in the scene in descending stacking order.
See also addItem(), removeItem(), and Sorting.
new System.Collections.Generic.List<IQGraphicsItem> QtGui.QGraphicsScene.Items | ( | Qt.SortOrder | order | ) |
Returns an ordered list of all items on the scene. order decides the stacking order.
See also addItem(), removeItem(), and Sorting.
new System.Collections.Generic.List<IQGraphicsItem> QtGui.QGraphicsScene.Items | ( | double | x, |
double | y, | ||
double | w, | ||
double | h, | ||
Qt.ItemSelectionMode | mode = Qt.ItemSelectionMode.IntersectsItemShape |
||
) |
Returns a list of all items in the scene in descending stacking order.
See also addItem(), removeItem(), and Sorting.
new System.Collections.Generic.List<IQGraphicsItem> QtGui.QGraphicsScene.Items | ( | double | x, |
double | y, | ||
double | w, | ||
double | h, | ||
Qt.ItemSelectionMode | mode, | ||
Qt.SortOrder | order | ||
) |
Returns a list of all items in the scene in descending stacking order.
See also addItem(), removeItem(), and Sorting.
new System.Collections.Generic.List<IQGraphicsItem> QtGui.QGraphicsScene.Items | ( | double | x, |
double | y, | ||
double | w, | ||
double | h, | ||
Qt.ItemSelectionMode | mode, | ||
Qt.SortOrder | order, | ||
QTransform | deviceTransform | ||
) |
Returns a list of all items in the scene in descending stacking order.
See also addItem(), removeItem(), and Sorting.
new QRectF QtGui.QGraphicsScene.ItemsBoundingRect | ( | ) |
Calculates and returns the bounding rect of all items on the scene. This function works by iterating over all items, and because if this, it can be slow for large scenes.
See also sceneRect().
new IQGraphicsItem QtGui.QGraphicsScene.MouseGrabberItem | ( | ) |
Returns the current mouse grabber item, or 0 if no item is currently grabbing the mouse. The mouse grabber item is the item that receives all mouse events sent to the scene.
An item becomes a mouse grabber when it receives and accepts a mouse press event, and it stays the mouse grabber until either of the following events occur:
If the item receives a mouse release event when there are no other buttons pressed, it loses the mouse grab.
If the item becomes invisible (i.e., someone calls item->setVisible(false)), or if it becomes disabled (i.e., someone calls item->setEnabled(false)), it loses the mouse grab.
If the item is removed from the scene, it loses the mouse grab.
If the item loses its mouse grab, the scene will ignore all mouse events until a new item grabs the mouse (i.e., until a new item receives a mouse press event).
|
protected |
This signal is emitted by QGraphicsScene when control reaches the event loop, if the scene content changes. The region parameter contains a list of scene rectangles that indicate the area that has been changed.
See also QGraphicsView::updateScene().
|
protectedvirtual |
This event handler, for event contextMenuEvent, can be reimplemented in a subclass to receive context menu events. The default implementation forwards the event to the topmost item that accepts context menu events at the position of the event. If no items accept context menu events at this position, the event is ignored.
See also QGraphicsItem::contextMenuEvent().
|
protectedvirtual |
This event handler, for event event, can be reimplemented in a subclass to receive drag enter events for the scene.
The default implementation accepts the event and prepares the scene to accept drag move events.
See also QGraphicsItem::dragEnterEvent(), dragMoveEvent(), dragLeaveEvent(), and dropEvent().
|
protectedvirtual |
This event handler, for event event, can be reimplemented in a subclass to receive drag leave events for the scene.
See also QGraphicsItem::dragLeaveEvent(), dragEnterEvent(), dragMoveEvent(), and dropEvent().
|
protectedvirtual |
This event handler, for event event, can be reimplemented in a subclass to receive drag move events for the scene.
See also QGraphicsItem::dragMoveEvent(), dragEnterEvent(), dragLeaveEvent(), and dropEvent().
|
protectedvirtual |
This event handler, for event event, can be reimplemented in a subclass to receive drop events for the scene.
See also QGraphicsItem::dropEvent(), dragEnterEvent(), dragMoveEvent(), and dragLeaveEvent().
override bool QtGui.QGraphicsScene.OnEvent | ( | QEvent @ | event | ) |
Reimplemented from QObject::event().
Processes the event event, and dispatches it to the respective event handlers.
In addition to calling the convenience event handlers, this function is responsible for converting mouse move events to hover events for when there is no mouse grabber item. Hover events are delivered directly to items; there is no convenience function for them.
Unlike QWidget, QGraphicsScene does not have the convenience functions enterEvent() and leaveEvent(). Use this function to obtain those events instead.
See also contextMenuEvent(), keyPressEvent(), keyReleaseEvent(), mousePressEvent(), mouseMoveEvent(), mouseReleaseEvent(), mouseDoubleClickEvent(), focusInEvent(), and focusOutEvent().
|
protectedvirtual |
This event handler, for event focusEvent, can be reimplemented in a subclass to receive focus in events.
The default implementation sets focus on the scene, and then on the last focus item.
See also QGraphicsItem::focusOutEvent().
|
protectedvirtual |
This event handler, for event focusEvent, can be reimplemented in a subclass to receive focus out events.
The default implementation removes focus from any focus item, then removes focus from the scene.
See also QGraphicsItem::focusInEvent().
|
protectedvirtual |
This event handler, for event helpEvent, can be reimplemented in a subclass to receive help events. The events are of type QEvent::ToolTip, which are created when a tooltip is requested.
The default implementation shows the tooltip of the topmost item, i.e., the item with the highest z-value, at the mouse cursor position. If no item has a tooltip set, this function does nothing.
See also QGraphicsItem::toolTip() and QGraphicsSceneHelpEvent.
|
protectedvirtual |
This event handler, for event event, can be reimplemented in a subclass to receive input method events for the scene.
The default implementation forwards the event to the focusItem(). If no item currently has focus or the current focus item does not accept input methods, this function does nothing.
See also QGraphicsItem::inputMethodEvent().
|
protectedvirtual |
This event handler, for event keyEvent, can be reimplemented in a subclass to receive keypress events. The default implementation forwards the event to current focus item.
See also QGraphicsItem::keyPressEvent() and focusItem().
|
protectedvirtual |
This event handler, for event keyEvent, can be reimplemented in a subclass to receive key release events. The default implementation forwards the event to current focus item.
See also QGraphicsItem::keyReleaseEvent() and focusItem().
|
protectedvirtual |
This event handler, for event mouseEvent, can be reimplemented in a subclass to receive mouse doubleclick events for the scene.
If someone doubleclicks on the scene, the scene will first receive a mouse press event, followed by a release event (i.e., a click), then a doubleclick event, and finally a release event. If the doubleclick event is delivered to a different item than the one that received the first press and release, it will be delivered as a press event. However, tripleclick events are not delivered as doubleclick events in this case.
The default implementation is similar to mousePressEvent().
See also QGraphicsItem::mousePressEvent(), QGraphicsItem::mouseMoveEvent(), QGraphicsItem::mouseReleaseEvent(), and QGraphicsItem::setAcceptedMouseButtons().
|
protectedvirtual |
This event handler, for event mouseEvent, can be reimplemented in a subclass to receive mouse move events for the scene.
The default implementation depends on the mouse grabber state. If there is a mouse grabber item, the event is sent to the mouse grabber. If there are any items that accept hover events at the current position, the event is translated into a hover event and accepted; otherwise it's ignored.
See also QGraphicsItem::mousePressEvent(), QGraphicsItem::mouseReleaseEvent(), QGraphicsItem::mouseDoubleClickEvent(), and QGraphicsItem::setAcceptedMouseButtons().
|
protectedvirtual |
This event handler, for event mouseEvent, can be reimplemented in a subclass to receive mouse press events for the scene.
The default implementation depends on the state of the scene. If there is a mouse grabber item, then the event is sent to the mouse grabber. Otherwise, it is forwarded to the topmost item that accepts mouse events at the scene position from the event, and that item promptly becomes the mouse grabber item.
If there is no item at the given position on the scene, the selection area is reset, any focus item loses its input focus, and the event is then ignored.
See also QGraphicsItem::mousePressEvent() and QGraphicsItem::setAcceptedMouseButtons().
|
protectedvirtual |
This event handler, for event mouseEvent, can be reimplemented in a subclass to receive mouse release events for the scene.
The default implementation depends on the mouse grabber state. If there is no mouse grabber, the event is ignored. Otherwise, if there is a mouse grabber item, the event is sent to the mouse grabber. If this mouse release represents the last pressed button on the mouse, the mouse grabber item then loses the mouse grab.
See also QGraphicsItem::mousePressEvent(), QGraphicsItem::mouseMoveEvent(), QGraphicsItem::mouseDoubleClickEvent(), and QGraphicsItem::setAcceptedMouseButtons().
|
protected |
This signal is emitted by QGraphicsScene whenever the scene rect changes. The rect parameter is the new scene rectangle.
See also QGraphicsView::updateSceneRect().
|
protected |
This signal is emitted by QGraphicsScene whenever the selection changes. You can call selectedItems() to get the new list of selected items.
The selection changes whenever an item is selected or unselected, a selection area is set, cleared or otherwise changed, if a preselected item is added to the scene, or if a selected item is removed from the scene.
QGraphicsScene emits this signal only once for group selection operations. For example, if you set a selection area, select or unselect a QGraphicsItemGroup, or if you add or remove from the scene a parent item that contains several selected items, selectionChanged() is emitted only once after the operation has completed (instead of once for each item).
This function was introduced in Qt 4.3.
See also setSelectionArea(), selectedItems(), and QGraphicsItem::setSelected().
new bool QtGui.QGraphicsScene.OnSendEvent | ( | IQGraphicsItem | item, |
QEvent @ | event | ||
) |
Sends event event to item item through possible event filters.
The event is sent only if the item is enabled.
Returns false if the event was filtered or if the item is disabled. Otherwise returns the value that was returned from the event handler.
This function was introduced in Qt 4.6.
See also QGraphicsItem::sceneEvent() and QGraphicsItem::sceneEventFilter().
|
protectedvirtual |
This event handler, for event wheelEvent, can be reimplemented in a subclass to receive mouse wheel events for the scene.
By default, the event is delivered to the topmost visible item under the cursor. If ignored, the event propagates to the item beneath, and again until the event is accepted, or it reaches the scene. If no items accept the event, it is ignored.
See also QGraphicsItem::wheelEvent().
new void QtGui.QGraphicsScene.RemoveItem | ( | IQGraphicsItem | item | ) |
Removes the item item and all its children from the scene. The ownership of item is passed on to the caller (i.e., QGraphicsScene will no longer delete item when destroyed).
See also addItem().
new void QtGui.QGraphicsScene.Render | ( | QPainter | painter | ) |
Renders the source rect from scene into target, using painter. This function is useful for capturing the contents of the scene onto a paint device, such as a QImage (e.g., to take a screenshot), or for printing with QPrinter. For example:
QGraphicsScene scene;
scene.addItem(...
...
QPrinter printer(QPrinter::HighResolution);
printer.setPaperSize(QPrinter::A4);
QPainter painter(&printer);
scene.render(&painter);
If source is a null rect, this function will use sceneRect() to determine what to render. If target is a null rect, the dimensions of painter's paint device will be used.
The source rect contents will be transformed according to aspectRatioMode to fit into the target rect. By default, the aspect ratio is kept, and source is scaled to fit in target.
See also QGraphicsView::render().
Renders the source rect from scene into target, using painter. This function is useful for capturing the contents of the scene onto a paint device, such as a QImage (e.g., to take a screenshot), or for printing with QPrinter. For example:
QGraphicsScene scene;
scene.addItem(...
...
QPrinter printer(QPrinter::HighResolution);
printer.setPaperSize(QPrinter::A4);
QPainter painter(&printer);
scene.render(&painter);
If source is a null rect, this function will use sceneRect() to determine what to render. If target is a null rect, the dimensions of painter's paint device will be used.
The source rect contents will be transformed according to aspectRatioMode to fit into the target rect. By default, the aspect ratio is kept, and source is scaled to fit in target.
See also QGraphicsView::render().
new void QtGui.QGraphicsScene.Render | ( | QPainter | painter, |
QRectF | target, | ||
QRectF | source, | ||
Qt.AspectRatioMode | aspectRatioMode = Qt.AspectRatioMode.KeepAspectRatio |
||
) |
Renders the source rect from scene into target, using painter. This function is useful for capturing the contents of the scene onto a paint device, such as a QImage (e.g., to take a screenshot), or for printing with QPrinter. For example:
QGraphicsScene scene;
scene.addItem(...
...
QPrinter printer(QPrinter::HighResolution);
printer.setPaperSize(QPrinter::A4);
QPainter painter(&printer);
scene.render(&painter);
If source is a null rect, this function will use sceneRect() to determine what to render. If target is a null rect, the dimensions of painter's paint device will be used.
The source rect contents will be transformed according to aspectRatioMode to fit into the target rect. By default, the aspect ratio is kept, and source is scaled to fit in target.
See also QGraphicsView::render().
new System.Collections.Generic.List<IQGraphicsItem> QtGui.QGraphicsScene.SelectedItems | ( | ) |
Returns a list of all currently selected items. The items are returned in no particular order.
See also setSelectionArea().
new void QtGui.QGraphicsScene.SetFocus | ( | Qt.FocusReason | focusReason = Qt.FocusReason.OtherFocusReason | ) |
Sets focus on the scene by sending a QFocusEvent to the scene, passing focusReason as the reason. If the scene regains focus after having previously lost it while an item had focus, the last focus item will receive focus with focusReason as the reason.
If the scene already has focus, this function does nothing.
See also hasFocus(), clearFocus(), and setFocusItem().
new void QtGui.QGraphicsScene.SetFocusItem | ( | IQGraphicsItem | item, |
Qt.FocusReason | focusReason = Qt.FocusReason.OtherFocusReason |
||
) |
Sets the scene's focus item to item, with the focus reason focusReason, after removing focus from any previous item that may have had focus.
If item is 0, or if it either does not accept focus (i.e., it does not have the QGraphicsItem::ItemIsFocusable flag enabled), or is not visible or not enabled, this function only removes focus from any previous focusitem.
If item is not 0, and the scene does not currently have focus (i.e., hasFocus() returns false), this function will call setFocus() automatically.
See also focusItem(), hasFocus(), and setFocus().
new void QtGui.QGraphicsScene.SetSceneRect | ( | double | x, |
double | y, | ||
double | w, | ||
double | h | ||
) |
new void QtGui.QGraphicsScene.SetSelectionArea | ( | QPainterPath | path, |
QTransform | deviceTransform | ||
) |
Sets the selection area to path. All items within this area are immediately selected, and all items outside are unselected. You can get the list of all selected items by calling selectedItems().
deviceTransform is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.
For an item to be selected, it must be marked as selectable (QGraphicsItem::ItemIsSelectable).
This function was introduced in Qt 4.6.
See also clearSelection() and selectionArea().
new void QtGui.QGraphicsScene.SetSelectionArea | ( | QPainterPath | path, |
Qt.ItemSelectionMode | mode | ||
) |
Sets the selection area to path. All items within this area are immediately selected, and all items outside are unselected. You can get the list of all selected items by calling selectedItems().
deviceTransform is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.
For an item to be selected, it must be marked as selectable (QGraphicsItem::ItemIsSelectable).
This function was introduced in Qt 4.6.
See also clearSelection() and selectionArea().
new void QtGui.QGraphicsScene.SetSelectionArea | ( | QPainterPath | path, |
Qt.ItemSelectionMode | mode, | ||
QTransform | deviceTransform | ||
) |
This is an overloaded function.
Sets the selection area to path using mode to determine if items are included in the selection area.
deviceTransform is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.
This function was introduced in Qt 4.6.
See also clearSelection() and selectionArea().
|
static |
|
static |
|
static |
|
static |
new void QtGui.QGraphicsScene.Update | ( | ) |
Schedules a redraw of the area rect on the scene.
See also sceneRect() and changed().
new void QtGui.QGraphicsScene.Update | ( | QRectF | rect | ) |
Schedules a redraw of the area rect on the scene.
See also sceneRect() and changed().
new void QtGui.QGraphicsScene.Update | ( | double | x, |
double | y, | ||
double | w, | ||
double | h | ||
) |
Schedules a redraw of the area rect on the scene.
See also sceneRect() and changed().
new System.Collections.Generic.List<QGraphicsView> QtGui.QGraphicsScene.Views | ( | ) |
Returns a list of all the views that display this scene.
See also QGraphicsView::scene().
new double QtGui.QGraphicsScene.Width | ( | ) |
This convenience function is equivalent to calling sceneRect().width().
See also height().
|
getset |
Returns the current active panel, or 0 if no panel is currently active.
This function was introduced in Qt 4.6.
Activates item, which must be an item in this scene. You can also pass 0 for item, in which case QGraphicsScene will deactivate any currently active panel.
If the scene is currently inactive, item remains inactive until the scene becomes active (or, ir item is 0, no item will be activated).
This function was introduced in Qt 4.6.
|
getset |
Returns the current active window, or 0 if no window is currently active.
This function was introduced in Qt 4.4.
Activates widget, which must be a widget in this scene. You can also pass 0 for widget, in which case QGraphicsScene will deactivate any currently active window.
This function was introduced in Qt 4.4.
|
getset |
This property holds the background brush of the scene.
Set this property to changes the scene's background to a different color, gradient or texture. The default background brush is Qt::NoBrush. The background is drawn before (behind) the items.
Example:
QGraphicsScene scene;
QGraphicsView view(&scene);
view.show();
// a blue background
scene.setBackgroundBrush(Qt::blue);
// a gradient background
QRadialGradient gradient(0, 0, 10);
gradient.setSpread(QGradient::RepeatSpread);
scene.setBackgroundBrush(gradient);
QGraphicsScene::render() calls drawBackground() to draw the scene background. For more detailed control over how the background is drawn, you can reimplement drawBackground() in a subclass of QGraphicsScene.
|
getset |
This property holds the depth of QGraphicsScene's BSP index tree.
This property has no effect when NoIndex is used.
This value determines the depth of QGraphicsScene's BSP tree. The depth directly affects QGraphicsScene's performance and memory usage; the latter growing exponentially with the depth of the tree. With an optimal tree depth, QGraphicsScene can instantly determine the locality of items, even for scenes with thousands or millions of items. This also greatly improves rendering performance.
By default, the value is 0, in which case Qt will guess a reasonable default depth based on the size, location and number of items in the scene. If these parameters change frequently, however, you may experience slowdowns as QGraphicsScene retunes the depth internally. You can avoid potential slowdowns by fixating the tree depth through setting this property.
The depth of the tree and the size of the scene rectangle decide the granularity of the scene's partitioning. The size of each scene segment is determined by the following algorithm:
QSizeF segmentSize = sceneRect().size() / pow(2, depth - 1);
The BSP tree has an optimal size when each segment contains between 0 and 10 items.
This property was introduced in Qt 4.3.
|
addremove |
This signal is emitted by QGraphicsScene when control reaches the event loop, if the scene content changes. The region parameter contains a list of scene rectangles that indicate the area that has been changed.
See also QGraphicsView::updateScene().
|
getprotected |
|
get |
When the scene is active, this functions returns the scene's current focus item, or 0 if no item currently has focus. When the scene is inactive, this functions returns the item that will gain input focus when the scene becomes active.
The focus item receives keyboard input when the scene receives a key event.
See also setFocusItem(), QGraphicsItem::hasFocus(), and isActive().
|
getset |
This property holds the scene's default font.
This property provides the scene's font. The scene font defaults to, and resolves all its entries from, QApplication::font.
If the scene's font changes, either directly through setFont() or indirectly when the application font changes, QGraphicsScene first sends itself a FontChange event, and it then sends FontChange events to all top-level widget items in the scene. These items respond by resolving their own fonts to the scene, and they then notify their children, who again notify their children, and so on, until all widget items have updated their fonts.
Changing the scene font, (directly or indirectly through QApplication::setFont(),) automatically schedules a redraw the entire scene.
This property was introduced in Qt 4.4.
|
getset |
This property holds the foreground brush of the scene.
Change this property to set the scene's foreground to a different color, gradient or texture.
The foreground is drawn after (on top of) the items. The default foreground brush is Qt::NoBrush ( i.e. the foreground is not drawn).
Example:
QGraphicsScene scene;
QGraphicsView view(&scene);
view.show();
// a white semi-transparent foreground
scene.setForegroundBrush(QColor(255, 255, 255, 127));
// a grid foreground
scene.setForegroundBrush(QBrush(Qt::lightGray, Qt::CrossPattern));
QGraphicsScene::render() calls drawForeground() to draw the scene foreground. For more detailed control over how the foreground is drawn, you can reimplement the drawForeground() function in a QGraphicsScene subclass.
|
getset |
This property holds the item indexing method.
QGraphicsScene applies an indexing algorithm to the scene, to speed up item discovery functions like items() and itemAt(). Indexing is most efficient for static scenes (i.e., where items don't move around). For dynamic scenes, or scenes with many animated items, the index bookkeeping can outweight the fast lookup speeds.
For the common case, the default index method BspTreeIndex works fine. If your scene uses many animations and you are experiencing slowness, you can disable indexing by calling setItemIndexMethod(NoIndex).
|
getset |
This property holds the scene's default palette.
This property provides the scene's palette. The scene palette defaults to, and resolves all its entries from, QApplication::palette.
If the scene's palette changes, either directly through setPalette() or indirectly when the application palette changes, QGraphicsScene first sends itself a PaletteChange event, and it then sends PaletteChange events to all top-level widget items in the scene. These items respond by resolving their own palettes to the scene, and they then notify their children, who again notify their children, and so on, until all widget items have updated their palettes.
Changing the scene palette, (directly or indirectly through QApplication::setPalette(),) automatically schedules a redraw the entire scene.
This property was introduced in Qt 4.4.
|
getset |
This property holds the scene rectangle; the bounding rectangle of the scene.
The scene rectangle defines the extent of the scene. It is primarily used by QGraphicsView to determine the view's default scrollable area, and by QGraphicsScene to manage item indexing.
If unset, or if set to a null QRectF, sceneRect() will return the largest bounding rect of all items on the scene since the scene was created (i.e., a rectangle that grows when items are added to or moved in the scene, but never shrinks).
|
addremove |
This signal is emitted by QGraphicsScene whenever the scene rect changes. The rect parameter is the new scene rectangle.
See also QGraphicsView::updateSceneRect().
|
getset |
Returns the selection area that was previously set with setSelectionArea(), or an empty QPainterPath if no selection area has been set.
Sets the selection area to path. All items within this area are immediately selected, and all items outside are unselected. You can get the list of all selected items by calling selectedItems().
deviceTransform is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.
For an item to be selected, it must be marked as selectable (QGraphicsItem::ItemIsSelectable).
This function was introduced in Qt 4.6.
|
addremove |
This signal is emitted by QGraphicsScene whenever the selection changes. You can call selectedItems() to get the new list of selected items.
The selection changes whenever an item is selected or unselected, a selection area is set, cleared or otherwise changed, if a preselected item is added to the scene, or if a selected item is removed from the scene.
QGraphicsScene emits this signal only once for group selection operations. For example, if you set a selection area, select or unselect a QGraphicsItemGroup, or if you add or remove from the scene a parent item that contains several selected items, selectionChanged() is emitted only once after the operation has completed (instead of once for each item).
This function was introduced in Qt 4.3.
See also setSelectionArea(), selectedItems(), and QGraphicsItem::setSelected().
|
getset |
This property holds whether sort caching is enabled.
Since Qt 4.6, this property has no effect.
This property was introduced in Qt 4.5.
|
staticget |
|
getset |
This property holds whether clicking into the scene background will clear focus.
In a QGraphicsScene with stickyFocus set to true, focus will remain unchanged when the user clicks into the scene background or on an item that does not accept focus. Otherwise, focus will be cleared.
By default, this property is false.
Focus changes in response to a mouse press. You can reimplement mousePressEvent() in a subclass of QGraphicsScene to toggle this property based on where the user has clicked.
This property was introduced in Qt 4.6.
|
getset |
Returns the scene's style, or the same as QApplication::style() if the scene has not been explicitly assigned a style.
This function was introduced in Qt 4.4.
Sets or replaces the style of the scene to style, and reparents the style to this scene. Any previously assigned style is deleted. The scene's style defaults to QApplication::style(), and serves as the default for all QGraphicsWidget items in the scene.
Changing the style, either directly by calling this function, or indirectly by calling QApplication::setStyle(), will automatically update the style for all widgets in the scene that do not have a style explicitly assigned to them.
If style is 0, QGraphicsScene will revert to QApplication::style().
This function was introduced in Qt 4.4.