Struct QGraphicsScene

Source
#[repr(C)]
pub struct QGraphicsScene { /* private fields */ }
Expand description

The QGraphicsScene class provides a surface for managing a large number of 2D graphical items.

C++ class: QGraphicsScene.

C++ documentation:

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 a 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.

Implementations§

Source§

impl QGraphicsScene

Source

pub fn slot_update(&self) -> Receiver<(*const QRectF,)>

Schedules a redraw of the area rect on the scene.

Returns a built-in Qt slot QGraphicsScene::update that can be passed to qt_core::Signal::connect.

C++ documentation:

Schedules a redraw of the area rect on the scene.

See also sceneRect() and changed().

Source

pub fn slot_invalidate(&self) -> Receiver<(*const QRectF, c_int)>

Invalidates and schedules a redraw of the layers in rect on the scene. Any cached content in layers is unconditionally invalidated and redrawn.

Returns a built-in Qt slot QGraphicsScene::invalidate that can be passed to qt_core::Signal::connect.

C++ documentation:

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().

Source

pub fn slot_advance(&self) -> Receiver<()>

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.

Returns a built-in Qt slot QGraphicsScene::advance that can be passed to qt_core::Signal::connect.

C++ documentation:

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.

Note that you can also use the Animation Framework for animations.

See also QGraphicsItem::advance() and QTimeLine.

Source

pub fn slot_clear_selection(&self) -> Receiver<()>

Clears the current selection.

Returns a built-in Qt slot QGraphicsScene::clearSelection that can be passed to qt_core::Signal::connect.

C++ documentation:

Clears the current selection.

See also setSelectionArea() and selectedItems().

Source

pub fn slot_clear(&self) -> Receiver<()>

Removes and deletes all items from the scene, but otherwise leaves the state of the scene unchanged.

Returns a built-in Qt slot QGraphicsScene::clear that can be passed to qt_core::Signal::connect.

C++ documentation:

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().

Source

pub fn slot_focus_next_prev_child(&self) -> Receiver<(bool,)>

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.

Returns a built-in Qt slot QGraphicsScene::focusNextPrevChild that can be passed to qt_core::Signal::connect.

C++ documentation:

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.

Source

pub fn scene_rect_changed(&self) -> Signal<(*const QRectF,)>

This signal is emitted by QGraphicsScene whenever the scene rect changes. The rect parameter is the new scene rectangle.

Returns a built-in Qt signal QGraphicsScene::sceneRectChanged that can be passed to qt_core::Signal::connect.

C++ documentation:

This signal is emitted by QGraphicsScene whenever the scene rect changes. The rect parameter is the new scene rectangle.

See also QGraphicsView::updateSceneRect().

Source

pub fn selection_changed(&self) -> Signal<()>

This signal is emitted by QGraphicsScene whenever the selection changes. You can call selectedItems() to get the new list of selected items.

Returns a built-in Qt signal QGraphicsScene::selectionChanged that can be passed to qt_core::Signal::connect.

C++ documentation:

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().

Source

pub fn focus_item_changed( &self, ) -> Signal<(*mut QGraphicsItem, *mut QGraphicsItem, FocusReason)>

This signal is emitted by QGraphicsScene whenever focus changes in the scene (i.e., when an item gains or loses input focus, or when focus passes from one item to another). You can connect to this signal if you need to keep track of when other items gain input focus. It is particularly useful for implementing virtual keyboards, input methods, and cursor items.

Returns a built-in Qt signal QGraphicsScene::focusItemChanged that can be passed to qt_core::Signal::connect.

C++ documentation:

This signal is emitted by QGraphicsScene whenever focus changes in the scene (i.e., when an item gains or loses input focus, or when focus passes from one item to another). You can connect to this signal if you need to keep track of when other items gain input focus. It is particularly useful for implementing virtual keyboards, input methods, and cursor items.

oldFocusItem is a pointer to the item that previously had focus, or 0 if no item had focus before the signal was emitted. newFocusItem is a pointer to the item that gained input focus, or 0 if focus was lost. reason is the reason for the focus change (e.g., if the scene was deactivated while an input field had focus, oldFocusItem would point to the input field item, newFocusItem would be 0, and reason would be Qt::ActiveWindowFocusReason.

Source

pub fn changed(&self) -> Signal<(*const QListOfQRectF,)>

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.

Returns a built-in Qt signal QGraphicsScene::changed that can be passed to qt_core::Signal::connect.

C++ documentation:

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().

Source

pub unsafe fn active_panel(&self) -> Ptr<QGraphicsItem>

Returns the current active panel, or 0 if no panel is currently active.

Calls C++ function: QGraphicsItem* QGraphicsScene::activePanel() const.

C++ documentation:

Returns the current active panel, or 0 if no panel is currently active.

This function was introduced in Qt 4.6.

See also QGraphicsScene::setActivePanel().

Source

pub unsafe fn active_window(&self) -> QPtr<QGraphicsWidget>

Returns the current active window, or 0 if no window is currently active.

Calls C++ function: QGraphicsWidget* QGraphicsScene::activeWindow() const.

C++ documentation:

Returns the current active window, or 0 if no window is currently active.

This function was introduced in Qt 4.4.

See also QGraphicsScene::setActiveWindow().

Source

pub unsafe fn add_ellipse_3a( &self, rect: impl CastInto<Ref<QRectF>>, pen: impl CastInto<Ref<QPen>>, brush: impl CastInto<Ref<QBrush>>, ) -> Ptr<QGraphicsEllipseItem>

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.

Calls C++ function: QGraphicsEllipseItem* QGraphicsScene::addEllipse(const QRectF& rect, const QPen& pen = …, const QBrush& brush = …).

C++ documentation:

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().

Source

pub unsafe fn add_ellipse_6a( &self, x: c_double, y: c_double, w: c_double, h: c_double, pen: impl CastInto<Ref<QPen>>, brush: impl CastInto<Ref<QBrush>>, ) -> Ptr<QGraphicsEllipseItem>

This convenience function is equivalent to calling addEllipse(QRectF(x, y, w, h), pen, brush).

Calls C++ function: QGraphicsEllipseItem* QGraphicsScene::addEllipse(double x, double y, double w, double h, const QPen& pen = …, const QBrush& brush = …).

C++ documentation:

This convenience function is equivalent to calling addEllipse(QRectF(x, y, w, h), pen, brush).

This function was introduced in Qt 4.3.

Source

pub unsafe fn add_ellipse_2a( &self, rect: impl CastInto<Ref<QRectF>>, pen: impl CastInto<Ref<QPen>>, ) -> Ptr<QGraphicsEllipseItem>

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.

Calls C++ function: QGraphicsEllipseItem* QGraphicsScene::addEllipse(const QRectF& rect, const QPen& pen = …).

C++ documentation:

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().

Source

pub unsafe fn add_ellipse_1a( &self, rect: impl CastInto<Ref<QRectF>>, ) -> Ptr<QGraphicsEllipseItem>

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.

Calls C++ function: QGraphicsEllipseItem* QGraphicsScene::addEllipse(const QRectF& rect).

C++ documentation:

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().

Source

pub unsafe fn add_ellipse_5a( &self, x: c_double, y: c_double, w: c_double, h: c_double, pen: impl CastInto<Ref<QPen>>, ) -> Ptr<QGraphicsEllipseItem>

This convenience function is equivalent to calling addEllipse(QRectF(x, y, w, h), pen, brush).

Calls C++ function: QGraphicsEllipseItem* QGraphicsScene::addEllipse(double x, double y, double w, double h, const QPen& pen = …).

C++ documentation:

This convenience function is equivalent to calling addEllipse(QRectF(x, y, w, h), pen, brush).

This function was introduced in Qt 4.3.

Source

pub unsafe fn add_ellipse_4a( &self, x: c_double, y: c_double, w: c_double, h: c_double, ) -> Ptr<QGraphicsEllipseItem>

This convenience function is equivalent to calling addEllipse(QRectF(x, y, w, h), pen, brush).

Calls C++ function: QGraphicsEllipseItem* QGraphicsScene::addEllipse(double x, double y, double w, double h).

C++ documentation:

This convenience function is equivalent to calling addEllipse(QRectF(x, y, w, h), pen, brush).

This function was introduced in Qt 4.3.

Source

pub unsafe fn add_item(&self, item: impl CastInto<Ptr<QGraphicsItem>>)

Adds or moves the item and all its childen to this scene. This scene takes ownership of the item.

Calls C++ function: void QGraphicsScene::addItem(QGraphicsItem* item).

C++ documentation:

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.

Source

pub unsafe fn add_line_2a( &self, line: impl CastInto<Ref<QLineF>>, pen: impl CastInto<Ref<QPen>>, ) -> Ptr<QGraphicsLineItem>

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.

Calls C++ function: QGraphicsLineItem* QGraphicsScene::addLine(const QLineF& line, const QPen& pen = …).

C++ documentation:

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().

Source

pub unsafe fn add_line_5a( &self, x1: c_double, y1: c_double, x2: c_double, y2: c_double, pen: impl CastInto<Ref<QPen>>, ) -> Ptr<QGraphicsLineItem>

This convenience function is equivalent to calling addLine(QLineF(x1, y1, x2, y2), pen).

Calls C++ function: QGraphicsLineItem* QGraphicsScene::addLine(double x1, double y1, double x2, double y2, const QPen& pen = …).

C++ documentation:

This convenience function is equivalent to calling addLine(QLineF(x1, y1, x2, y2), pen).

This function was introduced in Qt 4.3.

Source

pub unsafe fn add_line_1a( &self, line: impl CastInto<Ref<QLineF>>, ) -> Ptr<QGraphicsLineItem>

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.

Calls C++ function: QGraphicsLineItem* QGraphicsScene::addLine(const QLineF& line).

C++ documentation:

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().

Source

pub unsafe fn add_line_4a( &self, x1: c_double, y1: c_double, x2: c_double, y2: c_double, ) -> Ptr<QGraphicsLineItem>

This convenience function is equivalent to calling addLine(QLineF(x1, y1, x2, y2), pen).

Calls C++ function: QGraphicsLineItem* QGraphicsScene::addLine(double x1, double y1, double x2, double y2).

C++ documentation:

This convenience function is equivalent to calling addLine(QLineF(x1, y1, x2, y2), pen).

This function was introduced in Qt 4.3.

Source

pub unsafe fn add_path_3a( &self, path: impl CastInto<Ref<QPainterPath>>, pen: impl CastInto<Ref<QPen>>, brush: impl CastInto<Ref<QBrush>>, ) -> Ptr<QGraphicsPathItem>

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.

Calls C++ function: QGraphicsPathItem* QGraphicsScene::addPath(const QPainterPath& path, const QPen& pen = …, const QBrush& brush = …).

C++ documentation:

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().

Source

pub unsafe fn add_path_2a( &self, path: impl CastInto<Ref<QPainterPath>>, pen: impl CastInto<Ref<QPen>>, ) -> Ptr<QGraphicsPathItem>

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.

Calls C++ function: QGraphicsPathItem* QGraphicsScene::addPath(const QPainterPath& path, const QPen& pen = …).

C++ documentation:

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().

Source

pub unsafe fn add_path_1a( &self, path: impl CastInto<Ref<QPainterPath>>, ) -> Ptr<QGraphicsPathItem>

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.

Calls C++ function: QGraphicsPathItem* QGraphicsScene::addPath(const QPainterPath& path).

C++ documentation:

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().

Source

pub unsafe fn add_pixmap( &self, pixmap: impl CastInto<Ref<QPixmap>>, ) -> Ptr<QGraphicsPixmapItem>

Creates and adds a pixmap item to the scene, and returns the item pointer. The pixmap is defined by pixmap.

Calls C++ function: QGraphicsPixmapItem* QGraphicsScene::addPixmap(const QPixmap& pixmap).

C++ documentation:

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().

Source

pub unsafe fn add_polygon_3a( &self, polygon: impl CastInto<Ref<QPolygonF>>, pen: impl CastInto<Ref<QPen>>, brush: impl CastInto<Ref<QBrush>>, ) -> Ptr<QGraphicsPolygonItem>

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.

Calls C++ function: QGraphicsPolygonItem* QGraphicsScene::addPolygon(const QPolygonF& polygon, const QPen& pen = …, const QBrush& brush = …).

C++ documentation:

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().

Source

pub unsafe fn add_polygon_2a( &self, polygon: impl CastInto<Ref<QPolygonF>>, pen: impl CastInto<Ref<QPen>>, ) -> Ptr<QGraphicsPolygonItem>

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.

Calls C++ function: QGraphicsPolygonItem* QGraphicsScene::addPolygon(const QPolygonF& polygon, const QPen& pen = …).

C++ documentation:

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().

Source

pub unsafe fn add_polygon_1a( &self, polygon: impl CastInto<Ref<QPolygonF>>, ) -> Ptr<QGraphicsPolygonItem>

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.

Calls C++ function: QGraphicsPolygonItem* QGraphicsScene::addPolygon(const QPolygonF& polygon).

C++ documentation:

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().

Source

pub unsafe fn add_rect_3a( &self, rect: impl CastInto<Ref<QRectF>>, pen: impl CastInto<Ref<QPen>>, brush: impl CastInto<Ref<QBrush>>, ) -> Ptr<QGraphicsRectItem>

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.

Calls C++ function: QGraphicsRectItem* QGraphicsScene::addRect(const QRectF& rect, const QPen& pen = …, const QBrush& brush = …).

C++ documentation:

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().

Source

pub unsafe fn add_rect_6a( &self, x: c_double, y: c_double, w: c_double, h: c_double, pen: impl CastInto<Ref<QPen>>, brush: impl CastInto<Ref<QBrush>>, ) -> Ptr<QGraphicsRectItem>

This convenience function is equivalent to calling addRect(QRectF(x, y, w, h), pen, brush).

Calls C++ function: QGraphicsRectItem* QGraphicsScene::addRect(double x, double y, double w, double h, const QPen& pen = …, const QBrush& brush = …).

C++ documentation:

This convenience function is equivalent to calling addRect(QRectF(x, y, w, h), pen, brush).

This function was introduced in Qt 4.3.

Source

pub unsafe fn add_rect_2a( &self, rect: impl CastInto<Ref<QRectF>>, pen: impl CastInto<Ref<QPen>>, ) -> Ptr<QGraphicsRectItem>

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.

Calls C++ function: QGraphicsRectItem* QGraphicsScene::addRect(const QRectF& rect, const QPen& pen = …).

C++ documentation:

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().

Source

pub unsafe fn add_rect_1a( &self, rect: impl CastInto<Ref<QRectF>>, ) -> Ptr<QGraphicsRectItem>

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.

Calls C++ function: QGraphicsRectItem* QGraphicsScene::addRect(const QRectF& rect).

C++ documentation:

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().

Source

pub unsafe fn add_rect_5a( &self, x: c_double, y: c_double, w: c_double, h: c_double, pen: impl CastInto<Ref<QPen>>, ) -> Ptr<QGraphicsRectItem>

This convenience function is equivalent to calling addRect(QRectF(x, y, w, h), pen, brush).

Calls C++ function: QGraphicsRectItem* QGraphicsScene::addRect(double x, double y, double w, double h, const QPen& pen = …).

C++ documentation:

This convenience function is equivalent to calling addRect(QRectF(x, y, w, h), pen, brush).

This function was introduced in Qt 4.3.

Source

pub unsafe fn add_rect_4a( &self, x: c_double, y: c_double, w: c_double, h: c_double, ) -> Ptr<QGraphicsRectItem>

This convenience function is equivalent to calling addRect(QRectF(x, y, w, h), pen, brush).

Calls C++ function: QGraphicsRectItem* QGraphicsScene::addRect(double x, double y, double w, double h).

C++ documentation:

This convenience function is equivalent to calling addRect(QRectF(x, y, w, h), pen, brush).

This function was introduced in Qt 4.3.

Source

pub unsafe fn add_simple_text_2a( &self, text: impl CastInto<Ref<QString>>, font: impl CastInto<Ref<QFont>>, ) -> Ptr<QGraphicsSimpleTextItem>

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.

Calls C++ function: QGraphicsSimpleTextItem* QGraphicsScene::addSimpleText(const QString& text, const QFont& font = …).

C++ documentation:

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().

Source

pub unsafe fn add_simple_text_1a( &self, text: impl CastInto<Ref<QString>>, ) -> Ptr<QGraphicsSimpleTextItem>

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.

Calls C++ function: QGraphicsSimpleTextItem* QGraphicsScene::addSimpleText(const QString& text).

C++ documentation:

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().

Source

pub unsafe fn add_text_2a( &self, text: impl CastInto<Ref<QString>>, font: impl CastInto<Ref<QFont>>, ) -> QPtr<QGraphicsTextItem>

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.

Calls C++ function: QGraphicsTextItem* QGraphicsScene::addText(const QString& text, const QFont& font = …).

C++ documentation:

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().

Source

pub unsafe fn add_text_1a( &self, text: impl CastInto<Ref<QString>>, ) -> QPtr<QGraphicsTextItem>

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.

Calls C++ function: QGraphicsTextItem* QGraphicsScene::addText(const QString& text).

C++ documentation:

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().

Source

pub unsafe fn add_widget_2a( &self, widget: impl CastInto<Ptr<QWidget>>, w_flags: QFlags<WindowType>, ) -> QPtr<QGraphicsProxyWidget>

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.

Calls C++ function: QGraphicsProxyWidget* QGraphicsScene::addWidget(QWidget* widget, QFlags<Qt::WindowType> wFlags = …).

C++ documentation:

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().

Source

pub unsafe fn add_widget_1a( &self, widget: impl CastInto<Ptr<QWidget>>, ) -> QPtr<QGraphicsProxyWidget>

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.

Calls C++ function: QGraphicsProxyWidget* QGraphicsScene::addWidget(QWidget* widget).

C++ documentation:

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().

Source

pub unsafe fn advance(&self)

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.

Calls C++ function: [slot] void QGraphicsScene::advance().

C++ documentation:

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.

Note that you can also use the Animation Framework for animations.

See also QGraphicsItem::advance() and QTimeLine.

Source

pub unsafe fn background_brush(&self) -> CppBox<QBrush>

This property holds the background brush of the scene.

Calls C++ function: QBrush QGraphicsScene::backgroundBrush() const.

C++ documentation:

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.

Access functions:

QBrush backgroundBrush() const
void setBackgroundBrush(const QBrush &brush)
Source

pub unsafe fn bsp_tree_depth(&self) -> c_int

This property holds the depth of QGraphicsScene's BSP index tree

Calls C++ function: int QGraphicsScene::bspTreeDepth() const.

C++ documentation:

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.

Access functions:

int bspTreeDepth() const
void setBspTreeDepth(int depth)

See also itemIndexMethod.

Source

pub unsafe fn clear(&self)

Removes and deletes all items from the scene, but otherwise leaves the state of the scene unchanged.

Calls C++ function: [slot] void QGraphicsScene::clear().

C++ documentation:

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().

Source

pub unsafe fn clear_focus(&self)

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.

Calls C++ function: void QGraphicsScene::clearFocus().

C++ documentation:

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().

Source

pub unsafe fn clear_selection(&self)

Clears the current selection.

Calls C++ function: [slot] void QGraphicsScene::clearSelection().

C++ documentation:

Clears the current selection.

See also setSelectionArea() and selectedItems().

Source

pub unsafe fn colliding_items_2a( &self, item: impl CastInto<Ptr<QGraphicsItem>>, mode: ItemSelectionMode, ) -> CppBox<QListOfQGraphicsItem>

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.

Calls C++ function: QList<QGraphicsItem*> QGraphicsScene::collidingItems(const QGraphicsItem* item, Qt::ItemSelectionMode mode = …) const.

C++ documentation:

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.

Source

pub unsafe fn colliding_items_1a( &self, item: impl CastInto<Ptr<QGraphicsItem>>, ) -> CppBox<QListOfQGraphicsItem>

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.

Calls C++ function: QList<QGraphicsItem*> QGraphicsScene::collidingItems(const QGraphicsItem* item) const.

C++ documentation:

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.

Source

pub unsafe fn create_item_group( &self, items: impl CastInto<Ref<QListOfQGraphicsItem>>, ) -> Ptr<QGraphicsItemGroup>

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.

Calls C++ function: QGraphicsItemGroup* QGraphicsScene::createItemGroup(const QList<QGraphicsItem*>& items).

C++ documentation:

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().

Source

pub unsafe fn destroy_item_group( &self, group: impl CastInto<Ptr<QGraphicsItemGroup>>, )

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.

Calls C++ function: void QGraphicsScene::destroyItemGroup(QGraphicsItemGroup* group).

C++ documentation:

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().

Source

pub unsafe fn focus_item(&self) -> Ptr<QGraphicsItem>

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.

Calls C++ function: QGraphicsItem* QGraphicsScene::focusItem() const.

C++ documentation:

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().

Source

pub unsafe fn focus_on_touch(&self) -> bool

Available on cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

This property holds whether items gain focus when receiving a touch begin event.

Calls C++ function: bool QGraphicsScene::focusOnTouch() const.

C++ documentation:

This property holds whether items gain focus when receiving a touch begin event.

The usual behavior is to transfer focus only when an item is clicked. Often a tap on a touchpad is interpreted as equivalent to a mouse click by the operating system, generating a synthesized click event in response. However, at least on macOS you can configure this behavior.

By default, QGraphicsScene also transfers focus when you touch on a trackpad or similar. If the operating system is configured to not generate a synthetic mouse click on tapping the trackpad, this is surprising. If the operating system does generate synthetic mouse clicks on tapping the trackpad, the focus transfer on starting a touch gesture is unnecessary.

With focusOnTouch switched off, QGraphicsScene behaves as one would expect on macOS.

The default value is true, ensuring that the default behavior is just as in Qt versions prior to 5.12. Set to false to prevent touch events from triggering focus changes.

This property was introduced in Qt 5.12.

Access functions:

bool focusOnTouch() const
void setFocusOnTouch(bool enabled)
Source

pub unsafe fn font(&self) -> CppBox<QFont>

This property holds the scene's default font

Calls C++ function: QFont QGraphicsScene::font() const.

C++ documentation:

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.

Access functions:

QFont font() const
void setFont(const QFont &font)

See also QWidget::font, QApplication::setFont(), palette, and style().

Source

pub unsafe fn foreground_brush(&self) -> CppBox<QBrush>

This property holds the foreground brush of the scene.

Calls C++ function: QBrush QGraphicsScene::foregroundBrush() const.

C++ documentation:

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.

Access functions:

QBrush foregroundBrush() const
void setForegroundBrush(const QBrush &brush)
Source

pub unsafe fn has_focus(&self) -> bool

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.

Calls C++ function: bool QGraphicsScene::hasFocus() const.

C++ documentation:

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().

Source

pub unsafe fn height(&self) -> c_double

This convenience function is equivalent to calling sceneRect().height().

Calls C++ function: double QGraphicsScene::height() const.

C++ documentation:

This convenience function is equivalent to calling sceneRect().height().

See also width().

Source

pub unsafe fn input_method_query( &self, query: InputMethodQuery, ) -> CppBox<QVariant>

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.

Calls C++ function: virtual QVariant QGraphicsScene::inputMethodQuery(Qt::InputMethodQuery query) const.

C++ documentation:

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().

Source

pub unsafe fn invalidate_5a( &self, x: c_double, y: c_double, w: c_double, h: c_double, layers: QFlags<SceneLayer>, )

This is an overloaded function.

Calls C++ function: void QGraphicsScene::invalidate(double x, double y, double w, double h, QFlags<QGraphicsScene::SceneLayer> layers = …).

C++ documentation:

This is an overloaded function.

This convenience function is equivalent to calling invalidate(QRectF(x, y, w, h), layers);

This function was introduced in Qt 4.3.

Source

pub unsafe fn invalidate_2a( &self, rect: impl CastInto<Ref<QRectF>>, layers: QFlags<SceneLayer>, )

Invalidates and schedules a redraw of the layers in rect on the scene. Any cached content in layers is unconditionally invalidated and redrawn.

Calls C++ function: [slot] void QGraphicsScene::invalidate(const QRectF& rect = …, QFlags<QGraphicsScene::SceneLayer> layers = …).

C++ documentation:

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().

Source

pub unsafe fn invalidate_4a( &self, x: c_double, y: c_double, w: c_double, h: c_double, )

This is an overloaded function.

Calls C++ function: void QGraphicsScene::invalidate(double x, double y, double w, double h).

C++ documentation:

This is an overloaded function.

This convenience function is equivalent to calling invalidate(QRectF(x, y, w, h), layers);

This function was introduced in Qt 4.3.

Source

pub unsafe fn invalidate_1a(&self, rect: impl CastInto<Ref<QRectF>>)

Invalidates and schedules a redraw of the layers in rect on the scene. Any cached content in layers is unconditionally invalidated and redrawn.

Calls C++ function: [slot] void QGraphicsScene::invalidate(const QRectF& rect = …).

C++ documentation:

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().

Source

pub unsafe fn invalidate_0a(&self)

Invalidates and schedules a redraw of the layers in rect on the scene. Any cached content in layers is unconditionally invalidated and redrawn.

Calls C++ function: [slot] void QGraphicsScene::invalidate().

C++ documentation:

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().

Source

pub unsafe fn is_active(&self) -> bool

Returns true if the scene is active (e.g., it's viewed by at least one QGraphicsView that is active); otherwise returns false.

Calls C++ function: bool QGraphicsScene::isActive() const.

C++ documentation:

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().

Source

pub unsafe fn is_sort_cache_enabled(&self) -> bool

This property holds whether sort caching is enabled

Calls C++ function: bool QGraphicsScene::isSortCacheEnabled() const.

C++ documentation:

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.

Access functions:

bool isSortCacheEnabled() const
void setSortCacheEnabled(bool enabled)

Member Function Documentation

Source

pub unsafe fn item_at_2a( &self, pos: impl CastInto<Ref<QPointF>>, device_transform: impl CastInto<Ref<QTransform>>, ) -> Ptr<QGraphicsItem>

Returns the topmost visible item at the specified position, or 0 if there are no items at this position.

Calls C++ function: QGraphicsItem* QGraphicsScene::itemAt(const QPointF& pos, const QTransform& deviceTransform) const.

C++ documentation:

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.

Note: See items() for a definition of which items are considered visible by this function.

This function was introduced in Qt 4.6.

See also items(), collidingItems(), and Sorting.

Source

pub unsafe fn item_at_3a( &self, x: c_double, y: c_double, device_transform: impl CastInto<Ref<QTransform>>, ) -> Ptr<QGraphicsItem>

This is an overloaded function.

Calls C++ function: QGraphicsItem* QGraphicsScene::itemAt(double x, double y, const QTransform& deviceTransform) const.

C++ documentation:

This is an overloaded function.

Returns the topmost visible item at the position specified by (x, y), 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 convenience function is equivalent to calling itemAt(QPointF(x, y), deviceTransform).

Note: See items() for a definition of which items are considered visible by this function.

This function was introduced in Qt 4.6.

Source

pub unsafe fn item_index_method(&self) -> ItemIndexMethod

This property holds the item indexing method.

Calls C++ function: QGraphicsScene::ItemIndexMethod QGraphicsScene::itemIndexMethod() const.

C++ documentation:

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).

Access functions:

ItemIndexMethod itemIndexMethod() const
void setItemIndexMethod(ItemIndexMethod method)

See also bspTreeDepth.

Source

pub unsafe fn items_sort_order( &self, order: SortOrder, ) -> CppBox<QListOfQGraphicsItem>

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

Calls C++ function: QList<QGraphicsItem*> QGraphicsScene::items(Qt::SortOrder order = …) const.

Warning: no exact match found in C++ documentation. Below is the C++ documentation for QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const:

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.

This function was introduced in Qt 4.3.

Source

pub unsafe fn items_q_point_f_item_selection_mode_sort_order_q_transform( &self, pos: impl CastInto<Ref<QPointF>>, mode: ItemSelectionMode, order: SortOrder, device_transform: impl CastInto<Ref<QTransform>>, ) -> CppBox<QListOfQGraphicsItem>

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

Calls C++ function: QList<QGraphicsItem*> QGraphicsScene::items(const QPointF& pos, Qt::ItemSelectionMode mode = …, Qt::SortOrder order = …, const QTransform& deviceTransform = …) const.

Warning: no exact match found in C++ documentation. Below is the C++ documentation for QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const:

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.

This function was introduced in Qt 4.3.

Source

pub unsafe fn items_q_rect_f_item_selection_mode_sort_order_q_transform( &self, rect: impl CastInto<Ref<QRectF>>, mode: ItemSelectionMode, order: SortOrder, device_transform: impl CastInto<Ref<QTransform>>, ) -> CppBox<QListOfQGraphicsItem>

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

Calls C++ function: QList<QGraphicsItem*> QGraphicsScene::items(const QRectF& rect, Qt::ItemSelectionMode mode = …, Qt::SortOrder order = …, const QTransform& deviceTransform = …) const.

Warning: no exact match found in C++ documentation. Below is the C++ documentation for QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const:

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.

This function was introduced in Qt 4.3.

Source

pub unsafe fn items_q_polygon_f_item_selection_mode_sort_order_q_transform( &self, polygon: impl CastInto<Ref<QPolygonF>>, mode: ItemSelectionMode, order: SortOrder, device_transform: impl CastInto<Ref<QTransform>>, ) -> CppBox<QListOfQGraphicsItem>

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

Calls C++ function: QList<QGraphicsItem*> QGraphicsScene::items(const QPolygonF& polygon, Qt::ItemSelectionMode mode = …, Qt::SortOrder order = …, const QTransform& deviceTransform = …) const.

Warning: no exact match found in C++ documentation. Below is the C++ documentation for QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const:

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.

This function was introduced in Qt 4.3.

Source

pub unsafe fn items_q_painter_path_item_selection_mode_sort_order_q_transform( &self, path: impl CastInto<Ref<QPainterPath>>, mode: ItemSelectionMode, order: SortOrder, device_transform: impl CastInto<Ref<QTransform>>, ) -> CppBox<QListOfQGraphicsItem>

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

Calls C++ function: QList<QGraphicsItem*> QGraphicsScene::items(const QPainterPath& path, Qt::ItemSelectionMode mode = …, Qt::SortOrder order = …, const QTransform& deviceTransform = …) const.

Warning: no exact match found in C++ documentation. Below is the C++ documentation for QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const:

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.

This function was introduced in Qt 4.3.

Source

pub unsafe fn items_4_double_item_selection_mode_sort_order_q_transform( &self, x: c_double, y: c_double, w: c_double, h: c_double, mode: ItemSelectionMode, order: SortOrder, device_transform: impl CastInto<Ref<QTransform>>, ) -> CppBox<QListOfQGraphicsItem>

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

Calls C++ function: QList<QGraphicsItem*> QGraphicsScene::items(double x, double y, double w, double h, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform& deviceTransform = …) const.

Warning: no exact match found in C++ documentation. Below is the C++ documentation for QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const:

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.

This function was introduced in Qt 4.3.

Source

pub unsafe fn items(&self) -> CppBox<QListOfQGraphicsItem>

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

Calls C++ function: QList<QGraphicsItem*> QGraphicsScene::items() const.

Warning: no exact match found in C++ documentation. Below is the C++ documentation for QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const:

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.

This function was introduced in Qt 4.3.

Source

pub unsafe fn items_q_point_f_item_selection_mode_sort_order( &self, pos: impl CastInto<Ref<QPointF>>, mode: ItemSelectionMode, order: SortOrder, ) -> CppBox<QListOfQGraphicsItem>

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

Calls C++ function: QList<QGraphicsItem*> QGraphicsScene::items(const QPointF& pos, Qt::ItemSelectionMode mode = …, Qt::SortOrder order = …) const.

Warning: no exact match found in C++ documentation. Below is the C++ documentation for QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const:

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.

This function was introduced in Qt 4.3.

Source

pub unsafe fn items_q_point_f_item_selection_mode( &self, pos: impl CastInto<Ref<QPointF>>, mode: ItemSelectionMode, ) -> CppBox<QListOfQGraphicsItem>

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

Calls C++ function: QList<QGraphicsItem*> QGraphicsScene::items(const QPointF& pos, Qt::ItemSelectionMode mode = …) const.

Warning: no exact match found in C++ documentation. Below is the C++ documentation for QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const:

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.

This function was introduced in Qt 4.3.

Source

pub unsafe fn items_q_point_f( &self, pos: impl CastInto<Ref<QPointF>>, ) -> CppBox<QListOfQGraphicsItem>

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

Calls C++ function: QList<QGraphicsItem*> QGraphicsScene::items(const QPointF& pos) const.

Warning: no exact match found in C++ documentation. Below is the C++ documentation for QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const:

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.

This function was introduced in Qt 4.3.

Source

pub unsafe fn items_q_rect_f_item_selection_mode_sort_order( &self, rect: impl CastInto<Ref<QRectF>>, mode: ItemSelectionMode, order: SortOrder, ) -> CppBox<QListOfQGraphicsItem>

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

Calls C++ function: QList<QGraphicsItem*> QGraphicsScene::items(const QRectF& rect, Qt::ItemSelectionMode mode = …, Qt::SortOrder order = …) const.

Warning: no exact match found in C++ documentation. Below is the C++ documentation for QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const:

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.

This function was introduced in Qt 4.3.

Source

pub unsafe fn items_q_rect_f_item_selection_mode( &self, rect: impl CastInto<Ref<QRectF>>, mode: ItemSelectionMode, ) -> CppBox<QListOfQGraphicsItem>

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

Calls C++ function: QList<QGraphicsItem*> QGraphicsScene::items(const QRectF& rect, Qt::ItemSelectionMode mode = …) const.

Warning: no exact match found in C++ documentation. Below is the C++ documentation for QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const:

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.

This function was introduced in Qt 4.3.

Source

pub unsafe fn items_q_rect_f( &self, rect: impl CastInto<Ref<QRectF>>, ) -> CppBox<QListOfQGraphicsItem>

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

Calls C++ function: QList<QGraphicsItem*> QGraphicsScene::items(const QRectF& rect) const.

Warning: no exact match found in C++ documentation. Below is the C++ documentation for QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const:

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.

This function was introduced in Qt 4.3.

Source

pub unsafe fn items_q_polygon_f_item_selection_mode_sort_order( &self, polygon: impl CastInto<Ref<QPolygonF>>, mode: ItemSelectionMode, order: SortOrder, ) -> CppBox<QListOfQGraphicsItem>

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

Calls C++ function: QList<QGraphicsItem*> QGraphicsScene::items(const QPolygonF& polygon, Qt::ItemSelectionMode mode = …, Qt::SortOrder order = …) const.

Warning: no exact match found in C++ documentation. Below is the C++ documentation for QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const:

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.

This function was introduced in Qt 4.3.

Source

pub unsafe fn items_q_polygon_f_item_selection_mode( &self, polygon: impl CastInto<Ref<QPolygonF>>, mode: ItemSelectionMode, ) -> CppBox<QListOfQGraphicsItem>

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

Calls C++ function: QList<QGraphicsItem*> QGraphicsScene::items(const QPolygonF& polygon, Qt::ItemSelectionMode mode = …) const.

Warning: no exact match found in C++ documentation. Below is the C++ documentation for QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const:

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.

This function was introduced in Qt 4.3.

Source

pub unsafe fn items_q_polygon_f( &self, polygon: impl CastInto<Ref<QPolygonF>>, ) -> CppBox<QListOfQGraphicsItem>

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

Calls C++ function: QList<QGraphicsItem*> QGraphicsScene::items(const QPolygonF& polygon) const.

Warning: no exact match found in C++ documentation. Below is the C++ documentation for QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const:

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.

This function was introduced in Qt 4.3.

Source

pub unsafe fn items_q_painter_path_item_selection_mode_sort_order( &self, path: impl CastInto<Ref<QPainterPath>>, mode: ItemSelectionMode, order: SortOrder, ) -> CppBox<QListOfQGraphicsItem>

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

Calls C++ function: QList<QGraphicsItem*> QGraphicsScene::items(const QPainterPath& path, Qt::ItemSelectionMode mode = …, Qt::SortOrder order = …) const.

Warning: no exact match found in C++ documentation. Below is the C++ documentation for QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const:

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.

This function was introduced in Qt 4.3.

Source

pub unsafe fn items_q_painter_path_item_selection_mode( &self, path: impl CastInto<Ref<QPainterPath>>, mode: ItemSelectionMode, ) -> CppBox<QListOfQGraphicsItem>

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

Calls C++ function: QList<QGraphicsItem*> QGraphicsScene::items(const QPainterPath& path, Qt::ItemSelectionMode mode = …) const.

Warning: no exact match found in C++ documentation. Below is the C++ documentation for QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const:

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.

This function was introduced in Qt 4.3.

Source

pub unsafe fn items_q_painter_path( &self, path: impl CastInto<Ref<QPainterPath>>, ) -> CppBox<QListOfQGraphicsItem>

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

Calls C++ function: QList<QGraphicsItem*> QGraphicsScene::items(const QPainterPath& path) const.

Warning: no exact match found in C++ documentation. Below is the C++ documentation for QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const:

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.

This function was introduced in Qt 4.3.

Source

pub unsafe fn items_4_double_item_selection_mode_sort_order( &self, x: c_double, y: c_double, w: c_double, h: c_double, mode: ItemSelectionMode, order: SortOrder, ) -> CppBox<QListOfQGraphicsItem>

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

Calls C++ function: QList<QGraphicsItem*> QGraphicsScene::items(double x, double y, double w, double h, Qt::ItemSelectionMode mode, Qt::SortOrder order) const.

Warning: no exact match found in C++ documentation. Below is the C++ documentation for QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const:

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.

This function was introduced in Qt 4.3.

Source

pub unsafe fn items_bounding_rect(&self) -> CppBox<QRectF>

Calculates and returns the bounding rect of all items on the scene. This function works by iterating over all items, and because of this, it can be slow for large scenes.

Calls C++ function: QRectF QGraphicsScene::itemsBoundingRect() const.

C++ documentation:

Calculates and returns the bounding rect of all items on the scene. This function works by iterating over all items, and because of this, it can be slow for large scenes.

See also sceneRect().

Source

pub unsafe fn meta_object(&self) -> Ptr<QMetaObject>

Calls C++ function: virtual const QMetaObject* QGraphicsScene::metaObject() const.

Source

pub unsafe fn minimum_render_size(&self) -> c_double

This property holds the minimal view-transformed size an item must have to be drawn

Calls C++ function: double QGraphicsScene::minimumRenderSize() const.

C++ documentation:

This property holds the minimal view-transformed size an item must have to be drawn

When the scene is rendered, any item whose width or height, transformed to the target view, is smaller that minimumRenderSize(), will not be rendered. If an item is not rendered and it clips its children items they will also not be rendered. Set this value to speed up rendering of scenes with many objects rendered on a zoomed out view.

The default value is 0. If unset, or if set to 0 or a negative value, all items will always be rendered.

For example, setting this property can be especially useful if a scene is rendered by multiple views, one of which serves as an overview which always displays all items. In scenes with many items, such a view will use a high scaling factor so that all items can be shown. Due to the scaling, smaller items will only make an insignificant contribution to the final rendered scene. To avoid drawing these items and reduce the time necessary to render the scene, you can call setMinimumRenderSize() with a non-negative value.

Note: Items that are not drawn as a result of being too small, are still returned by methods such as items() and itemAt(), and participate in collision detection and interactions. It is recommended that you set minimumRenderSize() to a value less than or equal to 1 in order to avoid large unrendered items that are interactive.

This property was introduced in Qt 5.4.

Access functions:

qreal minimumRenderSize() const
void setMinimumRenderSize(qreal minSize)

See also QStyleOptionGraphicsItem::levelOfDetailFromTransform().

Source

pub unsafe fn mouse_grabber_item(&self) -> Ptr<QGraphicsItem>

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.

Calls C++ function: QGraphicsItem* QGraphicsScene::mouseGrabberItem() const.

C++ documentation:

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).

Source

pub unsafe fn from_q_object( parent: impl CastInto<Ptr<QObject>>, ) -> QBox<QGraphicsScene>

Constructs a QGraphicsScene object. The parent parameter is passed to QObject's constructor.

Calls C++ function: [constructor] void QGraphicsScene::QGraphicsScene(QObject* parent = …).

C++ documentation:

Constructs a QGraphicsScene object. The parent parameter is passed to QObject’s constructor.

Source

pub unsafe fn from_q_rect_f_q_object( scene_rect: impl CastInto<Ref<QRectF>>, parent: impl CastInto<Ptr<QObject>>, ) -> QBox<QGraphicsScene>

Constructs a QGraphicsScene object, using sceneRect for its scene rectangle. The parent parameter is passed to QObject's constructor.

Calls C++ function: [constructor] void QGraphicsScene::QGraphicsScene(const QRectF& sceneRect, QObject* parent = …).

C++ documentation:

Constructs a QGraphicsScene object, using sceneRect for its scene rectangle. The parent parameter is passed to QObject’s constructor.

See also sceneRect.

Source

pub unsafe fn from_4_double_q_object( x: c_double, y: c_double, width: c_double, height: c_double, parent: impl CastInto<Ptr<QObject>>, ) -> QBox<QGraphicsScene>

Constructs a QGraphicsScene object, using the rectangle specified by (x, y), and the given width and height for its scene rectangle. The parent parameter is passed to QObject's constructor.

Calls C++ function: [constructor] void QGraphicsScene::QGraphicsScene(double x, double y, double width, double height, QObject* parent = …).

C++ documentation:

Constructs a QGraphicsScene object, using the rectangle specified by (x, y), and the given width and height for its scene rectangle. The parent parameter is passed to QObject’s constructor.

See also sceneRect.

Source

pub unsafe fn new() -> QBox<QGraphicsScene>

The QGraphicsScene class provides a surface for managing a large number of 2D graphical items.

Calls C++ function: [constructor] void QGraphicsScene::QGraphicsScene().

C++ documentation:

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 a 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.

Source

pub unsafe fn from_q_rect_f( scene_rect: impl CastInto<Ref<QRectF>>, ) -> QBox<QGraphicsScene>

Constructs a QGraphicsScene object, using sceneRect for its scene rectangle. The parent parameter is passed to QObject's constructor.

Calls C++ function: [constructor] void QGraphicsScene::QGraphicsScene(const QRectF& sceneRect).

C++ documentation:

Constructs a QGraphicsScene object, using sceneRect for its scene rectangle. The parent parameter is passed to QObject’s constructor.

See also sceneRect.

Source

pub unsafe fn from_4_double( x: c_double, y: c_double, width: c_double, height: c_double, ) -> QBox<QGraphicsScene>

Constructs a QGraphicsScene object, using the rectangle specified by (x, y), and the given width and height for its scene rectangle. The parent parameter is passed to QObject's constructor.

Calls C++ function: [constructor] void QGraphicsScene::QGraphicsScene(double x, double y, double width, double height).

C++ documentation:

Constructs a QGraphicsScene object, using the rectangle specified by (x, y), and the given width and height for its scene rectangle. The parent parameter is passed to QObject’s constructor.

See also sceneRect.

Source

pub unsafe fn palette(&self) -> CppBox<QPalette>

This property holds the scene's default palette

Calls C++ function: QPalette QGraphicsScene::palette() const.

C++ documentation:

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.

Access functions:

QPalette palette() const
void setPalette(const QPalette &palette)

See also QWidget::palette, QApplication::setPalette(), font, and style().

Source

pub unsafe fn qt_metacall( &self, arg1: Call, arg2: c_int, arg3: *mut *mut c_void, ) -> c_int

Calls C++ function: virtual int QGraphicsScene::qt_metacall(QMetaObject::Call arg1, int arg2, void** arg3).

Source

pub unsafe fn qt_metacast(&self, arg1: *const c_char) -> *mut c_void

Calls C++ function: virtual void* QGraphicsScene::qt_metacast(const char* arg1).

Source

pub unsafe fn remove_item(&self, item: impl CastInto<Ptr<QGraphicsItem>>)

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).

Calls C++ function: void QGraphicsScene::removeItem(QGraphicsItem* item).

C++ documentation:

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().

Source

pub unsafe fn render_4a( &self, painter: impl CastInto<Ptr<QPainter>>, target: impl CastInto<Ref<QRectF>>, source: impl CastInto<Ref<QRectF>>, aspect_ratio_mode: AspectRatioMode, )

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:

Calls C++ function: void QGraphicsScene::render(QPainter* painter, const QRectF& target = …, const QRectF& source = …, Qt::AspectRatioMode aspectRatioMode = …).

C++ documentation:

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().

Source

pub unsafe fn render_3a( &self, painter: impl CastInto<Ptr<QPainter>>, target: impl CastInto<Ref<QRectF>>, source: impl CastInto<Ref<QRectF>>, )

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:

Calls C++ function: void QGraphicsScene::render(QPainter* painter, const QRectF& target = …, const QRectF& source = …).

C++ documentation:

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().

Source

pub unsafe fn render_2a( &self, painter: impl CastInto<Ptr<QPainter>>, target: impl CastInto<Ref<QRectF>>, )

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:

Calls C++ function: void QGraphicsScene::render(QPainter* painter, const QRectF& target = …).

C++ documentation:

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().

Source

pub unsafe fn render_1a(&self, painter: impl CastInto<Ptr<QPainter>>)

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:

Calls C++ function: void QGraphicsScene::render(QPainter* painter).

C++ documentation:

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().

Source

pub unsafe fn scene_rect(&self) -> CppBox<QRectF>

This property holds the scene rectangle; the bounding rectangle of the scene

Calls C++ function: QRectF QGraphicsScene::sceneRect() const.

C++ documentation:

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).

Access functions:

QRectF sceneRect() const
void setSceneRect(const QRectF &rect)
void setSceneRect(qreal x, qreal y, qreal w, qreal h)

See also width(), height(), and QGraphicsView::sceneRect.

Source

pub unsafe fn selected_items(&self) -> CppBox<QListOfQGraphicsItem>

Returns a list of all currently selected items. The items are returned in no particular order.

Calls C++ function: QList<QGraphicsItem*> QGraphicsScene::selectedItems() const.

C++ documentation:

Returns a list of all currently selected items. The items are returned in no particular order.

See also setSelectionArea().

Source

pub unsafe fn selection_area(&self) -> CppBox<QPainterPath>

Returns the selection area that was previously set with setSelectionArea(), or an empty QPainterPath if no selection area has been set.

Calls C++ function: QPainterPath QGraphicsScene::selectionArea() const.

C++ documentation:

Returns the selection area that was previously set with setSelectionArea(), or an empty QPainterPath if no selection area has been set.

See also setSelectionArea().

Source

pub unsafe fn send_event( &self, item: impl CastInto<Ptr<QGraphicsItem>>, event: impl CastInto<Ptr<QEvent>>, ) -> bool

Sends event event to item item through possible event filters.

Calls C++ function: bool QGraphicsScene::sendEvent(QGraphicsItem* item, QEvent* event).

C++ documentation:

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().

Source

pub unsafe fn set_active_panel(&self, item: impl CastInto<Ptr<QGraphicsItem>>)

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.

Calls C++ function: void QGraphicsScene::setActivePanel(QGraphicsItem* item).

C++ documentation:

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.

See also activePanel(), isActive(), and QGraphicsItem::isActive().

Source

pub unsafe fn set_active_window( &self, widget: impl CastInto<Ptr<QGraphicsWidget>>, )

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.

Calls C++ function: void QGraphicsScene::setActiveWindow(QGraphicsWidget* widget).

C++ documentation:

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.

See also activeWindow() and QGraphicsWidget::isActiveWindow().

Source

pub unsafe fn set_background_brush(&self, brush: impl CastInto<Ref<QBrush>>)

This property holds the background brush of the scene.

Calls C++ function: void QGraphicsScene::setBackgroundBrush(const QBrush& brush).

C++ documentation:

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.

Access functions:

QBrush backgroundBrush() const
void setBackgroundBrush(const QBrush &brush)
Source

pub unsafe fn set_bsp_tree_depth(&self, depth: c_int)

This property holds the depth of QGraphicsScene's BSP index tree

Calls C++ function: void QGraphicsScene::setBspTreeDepth(int depth).

C++ documentation:

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.

Access functions:

int bspTreeDepth() const
void setBspTreeDepth(int depth)

See also itemIndexMethod.

Source

pub unsafe fn set_focus_1a(&self, focus_reason: FocusReason)

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.

Calls C++ function: void QGraphicsScene::setFocus(Qt::FocusReason focusReason = …).

C++ documentation:

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().

Source

pub unsafe fn set_focus_0a(&self)

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.

Calls C++ function: void QGraphicsScene::setFocus().

C++ documentation:

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().

Source

pub unsafe fn set_focus_item_2a( &self, item: impl CastInto<Ptr<QGraphicsItem>>, focus_reason: FocusReason, )

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.

Calls C++ function: void QGraphicsScene::setFocusItem(QGraphicsItem* item, Qt::FocusReason focusReason = …).

C++ documentation:

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().

Source

pub unsafe fn set_focus_item_1a(&self, item: impl CastInto<Ptr<QGraphicsItem>>)

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.

Calls C++ function: void QGraphicsScene::setFocusItem(QGraphicsItem* item).

C++ documentation:

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().

Source

pub unsafe fn set_focus_on_touch(&self, enabled: bool)

Available on cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

This property holds whether items gain focus when receiving a touch begin event.

Calls C++ function: void QGraphicsScene::setFocusOnTouch(bool enabled).

C++ documentation:

This property holds whether items gain focus when receiving a touch begin event.

The usual behavior is to transfer focus only when an item is clicked. Often a tap on a touchpad is interpreted as equivalent to a mouse click by the operating system, generating a synthesized click event in response. However, at least on macOS you can configure this behavior.

By default, QGraphicsScene also transfers focus when you touch on a trackpad or similar. If the operating system is configured to not generate a synthetic mouse click on tapping the trackpad, this is surprising. If the operating system does generate synthetic mouse clicks on tapping the trackpad, the focus transfer on starting a touch gesture is unnecessary.

With focusOnTouch switched off, QGraphicsScene behaves as one would expect on macOS.

The default value is true, ensuring that the default behavior is just as in Qt versions prior to 5.12. Set to false to prevent touch events from triggering focus changes.

This property was introduced in Qt 5.12.

Access functions:

bool focusOnTouch() const
void setFocusOnTouch(bool enabled)
Source

pub unsafe fn set_font(&self, font: impl CastInto<Ref<QFont>>)

This property holds the scene's default font

Calls C++ function: void QGraphicsScene::setFont(const QFont& font).

C++ documentation:

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.

Access functions:

QFont font() const
void setFont(const QFont &font)

See also QWidget::font, QApplication::setFont(), palette, and style().

Source

pub unsafe fn set_foreground_brush(&self, brush: impl CastInto<Ref<QBrush>>)

This property holds the foreground brush of the scene.

Calls C++ function: void QGraphicsScene::setForegroundBrush(const QBrush& brush).

C++ documentation:

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.

Access functions:

QBrush foregroundBrush() const
void setForegroundBrush(const QBrush &brush)
Source

pub unsafe fn set_item_index_method(&self, method: ItemIndexMethod)

This property holds the item indexing method.

Calls C++ function: void QGraphicsScene::setItemIndexMethod(QGraphicsScene::ItemIndexMethod method).

C++ documentation:

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).

Access functions:

ItemIndexMethod itemIndexMethod() const
void setItemIndexMethod(ItemIndexMethod method)

See also bspTreeDepth.

Source

pub unsafe fn set_minimum_render_size(&self, min_size: c_double)

This property holds the minimal view-transformed size an item must have to be drawn

Calls C++ function: void QGraphicsScene::setMinimumRenderSize(double minSize).

C++ documentation:

This property holds the minimal view-transformed size an item must have to be drawn

When the scene is rendered, any item whose width or height, transformed to the target view, is smaller that minimumRenderSize(), will not be rendered. If an item is not rendered and it clips its children items they will also not be rendered. Set this value to speed up rendering of scenes with many objects rendered on a zoomed out view.

The default value is 0. If unset, or if set to 0 or a negative value, all items will always be rendered.

For example, setting this property can be especially useful if a scene is rendered by multiple views, one of which serves as an overview which always displays all items. In scenes with many items, such a view will use a high scaling factor so that all items can be shown. Due to the scaling, smaller items will only make an insignificant contribution to the final rendered scene. To avoid drawing these items and reduce the time necessary to render the scene, you can call setMinimumRenderSize() with a non-negative value.

Note: Items that are not drawn as a result of being too small, are still returned by methods such as items() and itemAt(), and participate in collision detection and interactions. It is recommended that you set minimumRenderSize() to a value less than or equal to 1 in order to avoid large unrendered items that are interactive.

This property was introduced in Qt 5.4.

Access functions:

qreal minimumRenderSize() const
void setMinimumRenderSize(qreal minSize)

See also QStyleOptionGraphicsItem::levelOfDetailFromTransform().

Source

pub unsafe fn set_palette(&self, palette: impl CastInto<Ref<QPalette>>)

This property holds the scene's default palette

Calls C++ function: void QGraphicsScene::setPalette(const QPalette& palette).

C++ documentation:

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.

Access functions:

QPalette palette() const
void setPalette(const QPalette &palette)

See also QWidget::palette, QApplication::setPalette(), font, and style().

Source

pub unsafe fn set_scene_rect_1a(&self, rect: impl CastInto<Ref<QRectF>>)

This property holds the scene rectangle; the bounding rectangle of the scene

Calls C++ function: void QGraphicsScene::setSceneRect(const QRectF& rect).

C++ documentation:

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).

Access functions:

QRectF sceneRect() const
void setSceneRect(const QRectF &rect)
void setSceneRect(qreal x, qreal y, qreal w, qreal h)

See also width(), height(), and QGraphicsView::sceneRect.

Source

pub unsafe fn set_scene_rect_4a( &self, x: c_double, y: c_double, w: c_double, h: c_double, )

This property holds the scene rectangle; the bounding rectangle of the scene

Calls C++ function: void QGraphicsScene::setSceneRect(double x, double y, double w, double h).

C++ documentation:

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).

Access functions:

QRectF sceneRect() const
void setSceneRect(const QRectF &rect)
void setSceneRect(qreal x, qreal y, qreal w, qreal h)

See also width(), height(), and QGraphicsView::sceneRect.

Source

pub unsafe fn set_selection_area_q_painter_path_q_transform( &self, path: impl CastInto<Ref<QPainterPath>>, device_transform: impl CastInto<Ref<QTransform>>, )

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().

Calls C++ function: void QGraphicsScene::setSelectionArea(const QPainterPath& path, const QTransform& deviceTransform).

C++ documentation:

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().

Source

pub unsafe fn set_selection_area_q_painter_path_item_selection_mode_q_transform( &self, path: impl CastInto<Ref<QPainterPath>>, mode: ItemSelectionMode, device_transform: impl CastInto<Ref<QTransform>>, )

This is an overloaded function.

Calls C++ function: void QGraphicsScene::setSelectionArea(const QPainterPath& path, Qt::ItemSelectionMode mode = …, const QTransform& deviceTransform = …).

C++ documentation:

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().

Source

pub unsafe fn set_selection_area_q_painter_path_item_selection_operation_item_selection_mode_q_transform( &self, path: impl CastInto<Ref<QPainterPath>>, selection_operation: ItemSelectionOperation, mode: ItemSelectionMode, device_transform: impl CastInto<Ref<QTransform>>, )

This is an overloaded function.

Calls C++ function: void QGraphicsScene::setSelectionArea(const QPainterPath& path, Qt::ItemSelectionOperation selectionOperation, Qt::ItemSelectionMode mode = …, const QTransform& deviceTransform = …).

C++ documentation:

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.

selectionOperation determines what to do with the currently selected items.

This function was introduced in Qt 5.5.

See also clearSelection() and selectionArea().

Source

pub unsafe fn set_selection_area_q_painter_path_item_selection_mode( &self, path: impl CastInto<Ref<QPainterPath>>, mode: ItemSelectionMode, )

This is an overloaded function.

Calls C++ function: void QGraphicsScene::setSelectionArea(const QPainterPath& path, Qt::ItemSelectionMode mode = …).

C++ documentation:

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().

Source

pub unsafe fn set_selection_area_q_painter_path( &self, path: impl CastInto<Ref<QPainterPath>>, )

This is an overloaded function.

Calls C++ function: void QGraphicsScene::setSelectionArea(const QPainterPath& path).

C++ documentation:

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().

Source

pub unsafe fn set_selection_area_q_painter_path_item_selection_operation_item_selection_mode( &self, path: impl CastInto<Ref<QPainterPath>>, selection_operation: ItemSelectionOperation, mode: ItemSelectionMode, )

This is an overloaded function.

Calls C++ function: void QGraphicsScene::setSelectionArea(const QPainterPath& path, Qt::ItemSelectionOperation selectionOperation, Qt::ItemSelectionMode mode = …).

C++ documentation:

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.

selectionOperation determines what to do with the currently selected items.

This function was introduced in Qt 5.5.

See also clearSelection() and selectionArea().

Source

pub unsafe fn set_selection_area_q_painter_path_item_selection_operation( &self, path: impl CastInto<Ref<QPainterPath>>, selection_operation: ItemSelectionOperation, )

This is an overloaded function.

Calls C++ function: void QGraphicsScene::setSelectionArea(const QPainterPath& path, Qt::ItemSelectionOperation selectionOperation).

C++ documentation:

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.

selectionOperation determines what to do with the currently selected items.

This function was introduced in Qt 5.5.

See also clearSelection() and selectionArea().

Source

pub unsafe fn set_sort_cache_enabled(&self, enabled: bool)

This property holds whether sort caching is enabled

Calls C++ function: void QGraphicsScene::setSortCacheEnabled(bool enabled).

C++ documentation:

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.

Access functions:

bool isSortCacheEnabled() const
void setSortCacheEnabled(bool enabled)

Member Function Documentation

Source

pub unsafe fn set_sticky_focus(&self, enabled: bool)

This property holds whether clicking into the scene background will clear focus

Calls C++ function: void QGraphicsScene::setStickyFocus(bool enabled).

C++ documentation:

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.

Access functions:

bool stickyFocus() const
void setStickyFocus(bool enabled)

See also clearFocus() and setFocusItem().

Source

pub unsafe fn set_style(&self, style: impl CastInto<Ptr<QStyle>>)

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.

Calls C++ function: void QGraphicsScene::setStyle(QStyle* style).

C++ documentation:

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.

See also style().

Source

pub unsafe fn static_meta_object() -> Ref<QMetaObject>

Returns a reference to the staticMetaObject field.

Source

pub unsafe fn sticky_focus(&self) -> bool

This property holds whether clicking into the scene background will clear focus

Calls C++ function: bool QGraphicsScene::stickyFocus() const.

C++ documentation:

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.

Access functions:

bool stickyFocus() const
void setStickyFocus(bool enabled)

See also clearFocus() and setFocusItem().

Source

pub unsafe fn style(&self) -> QPtr<QStyle>

Returns the scene's style, or the same as QApplication::style() if the scene has not been explicitly assigned a style.

Calls C++ function: QStyle* QGraphicsScene::style() const.

C++ documentation:

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.

See also setStyle().

Source

pub unsafe fn tr( s: *const c_char, c: *const c_char, n: c_int, ) -> CppBox<QString>

Calls C++ function: static QString QGraphicsScene::tr(const char* s, const char* c, int n).

Source

pub unsafe fn tr_utf8( s: *const c_char, c: *const c_char, n: c_int, ) -> CppBox<QString>

Calls C++ function: static QString QGraphicsScene::trUtf8(const char* s, const char* c, int n).

Source

pub unsafe fn update_4a( &self, x: c_double, y: c_double, w: c_double, h: c_double, )

This is an overloaded function.

Calls C++ function: void QGraphicsScene::update(double x, double y, double w, double h).

C++ documentation:

This is an overloaded function.

This function is equivalent to calling update(QRectF(x, y, w, h));

This function was introduced in Qt 4.3.

Source

pub unsafe fn update_1a(&self, rect: impl CastInto<Ref<QRectF>>)

Schedules a redraw of the area rect on the scene.

Calls C++ function: [slot] void QGraphicsScene::update(const QRectF& rect = …).

C++ documentation:

Schedules a redraw of the area rect on the scene.

See also sceneRect() and changed().

Source

pub unsafe fn update_0a(&self)

Schedules a redraw of the area rect on the scene.

Calls C++ function: [slot] void QGraphicsScene::update().

C++ documentation:

Schedules a redraw of the area rect on the scene.

See also sceneRect() and changed().

Source

pub unsafe fn views(&self) -> CppBox<QListOfQGraphicsView>

Returns a list of all the views that display this scene.

Calls C++ function: QList<QGraphicsView*> QGraphicsScene::views() const.

C++ documentation:

Returns a list of all the views that display this scene.

See also QGraphicsView::scene().

Source

pub unsafe fn width(&self) -> c_double

This convenience function is equivalent to calling sceneRect().width().

Calls C++ function: double QGraphicsScene::width() const.

C++ documentation:

This convenience function is equivalent to calling sceneRect().width().

See also height().

Methods from Deref<Target = QObject>§

Source

pub unsafe fn find_child<T>( &self, name: &str, ) -> Result<QPtr<T>, FindChildError>

Finds a child of self with the specified object name and casts it to type T.

The search is performed recursively. If there is more than one child matching the search, the most direct ancestor is returned. If there are several direct ancestors, it is undefined which one will be returned.

Returns an error if there is no child object with object name name or the found object cannot be cast to T.

Source

pub fn destroyed(&self) -> Signal<(*mut QObject,)>

This signal is emitted immediately before the object obj is destroyed, and can not be blocked.

Returns a built-in Qt signal QObject::destroyed that can be passed to qt_core::Signal::connect.

C++ documentation:

This signal is emitted immediately before the object obj is destroyed, and can not be blocked.

All the objects's children are destroyed immediately after this signal is emitted.

See also deleteLater() and QPointer.

Source

pub fn object_name_changed(&self) -> Signal<(*const QString,)>

This signal is emitted after the object's name has been changed. The new object name is passed as objectName.

Returns a built-in Qt signal QObject::objectNameChanged that can be passed to qt_core::Signal::connect.

C++ documentation:

This signal is emitted after the object’s name has been changed. The new object name is passed as objectName.

Note: This is a private signal. It can be used in signal connections but cannot be emitted by the user.

Note: Notifier signal for property objectName.

See also QObject::objectName.

Source

pub fn slot_delete_later(&self) -> Receiver<()>

Schedules this object for deletion.

Returns a built-in Qt slot QObject::deleteLater that can be passed to qt_core::Signal::connect.

C++ documentation:

Schedules this object for deletion.

The object will be deleted when control returns to the event loop. If the event loop is not running when this function is called (e.g. deleteLater() is called on an object before QCoreApplication::exec()), the object will be deleted once the event loop is started. If deleteLater() is called after the main event loop has stopped, the object will not be deleted. Since Qt 4.8, if deleteLater() is called on an object that lives in a thread with no running event loop, the object will be destroyed when the thread finishes.

Note that entering and leaving a new event loop (e.g., by opening a modal dialog) will not perform the deferred deletion; for the object to be deleted, the control must return to the event loop from which deleteLater() was called.

Note: It is safe to call this function more than once; when the first deferred deletion event is delivered, any pending events for the object are removed from the event queue.

See also destroyed() and QPointer.

Source

pub unsafe fn block_signals(&self, b: bool) -> bool

If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). If block is false, no such blocking will occur.

Calls C++ function: bool QObject::blockSignals(bool b).

C++ documentation:

If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). If block is false, no such blocking will occur.

The return value is the previous value of signalsBlocked().

Note that the destroyed() signal will be emitted even if the signals for this object have been blocked.

Signals emitted while being blocked are not buffered.

See also signalsBlocked() and QSignalBlocker.

Source

pub unsafe fn children(&self) -> Ref<QListOfQObject>

Returns a list of child objects. The QObjectList class is defined in the <QObject> header file as the following:

Calls C++ function: const QList<QObject*>& QObject::children() const.

C++ documentation:

Returns a list of child objects. The QObjectList class is defined in the <QObject> header file as the following:


  typedef QList<QObject*> QObjectList;

The first child added is the first object in the list and the last child added is the last object in the list, i.e. new children are appended at the end.

Note that the list order changes when QWidget children are raised or lowered. A widget that is raised becomes the last object in the list, and a widget that is lowered becomes the first object in the list.

See also findChild(), findChildren(), parent(), and setParent().

Source

pub unsafe fn delete_later(&self)

Schedules this object for deletion.

Calls C++ function: [slot] void QObject::deleteLater().

C++ documentation:

Schedules this object for deletion.

The object will be deleted when control returns to the event loop. If the event loop is not running when this function is called (e.g. deleteLater() is called on an object before QCoreApplication::exec()), the object will be deleted once the event loop is started. If deleteLater() is called after the main event loop has stopped, the object will not be deleted. Since Qt 4.8, if deleteLater() is called on an object that lives in a thread with no running event loop, the object will be destroyed when the thread finishes.

Note that entering and leaving a new event loop (e.g., by opening a modal dialog) will not perform the deferred deletion; for the object to be deleted, the control must return to the event loop from which deleteLater() was called.

Note: It is safe to call this function more than once; when the first deferred deletion event is delivered, any pending events for the object are removed from the event queue.

See also destroyed() and QPointer.

Source

pub unsafe fn disconnect_char_q_object_char( &self, signal: *const i8, receiver: impl CastInto<Ptr<QObject>>, member: *const i8, ) -> bool

This function overloads disconnect().

Calls C++ function: bool QObject::disconnect(const char* signal = …, const QObject* receiver = …, const char* member = …) const.

C++ documentation:

This function overloads disconnect().

Disconnects signal from method of receiver.

A signal-slot connection is removed when either of the objects involved are destroyed.

Note: This function is thread-safe.

Source

pub unsafe fn disconnect_q_object_char( &self, receiver: impl CastInto<Ptr<QObject>>, member: *const i8, ) -> bool

This function overloads disconnect().

Calls C++ function: bool QObject::disconnect(const QObject* receiver, const char* member = …) const.

C++ documentation:

This function overloads disconnect().

Disconnects all signals in this object from receiver's method.

A signal-slot connection is removed when either of the objects involved are destroyed.

Source

pub unsafe fn disconnect_char_q_object( &self, signal: *const i8, receiver: impl CastInto<Ptr<QObject>>, ) -> bool

This function overloads disconnect().

Calls C++ function: bool QObject::disconnect(const char* signal = …, const QObject* receiver = …) const.

C++ documentation:

This function overloads disconnect().

Disconnects signal from method of receiver.

A signal-slot connection is removed when either of the objects involved are destroyed.

Note: This function is thread-safe.

Source

pub unsafe fn disconnect_char(&self, signal: *const i8) -> bool

This function overloads disconnect().

Calls C++ function: bool QObject::disconnect(const char* signal = …) const.

C++ documentation:

This function overloads disconnect().

Disconnects signal from method of receiver.

A signal-slot connection is removed when either of the objects involved are destroyed.

Note: This function is thread-safe.

Source

pub unsafe fn disconnect(&self) -> bool

This function overloads disconnect().

Calls C++ function: bool QObject::disconnect() const.

C++ documentation:

This function overloads disconnect().

Disconnects signal from method of receiver.

A signal-slot connection is removed when either of the objects involved are destroyed.

Note: This function is thread-safe.

Source

pub unsafe fn disconnect_q_object( &self, receiver: impl CastInto<Ptr<QObject>>, ) -> bool

This function overloads disconnect().

Calls C++ function: bool QObject::disconnect(const QObject* receiver) const.

C++ documentation:

This function overloads disconnect().

Disconnects all signals in this object from receiver's method.

A signal-slot connection is removed when either of the objects involved are destroyed.

Source

pub unsafe fn dump_object_info_mut(&self)

Dumps information about signal connections, etc. for this object to the debug output.

Calls C++ function: void QObject::dumpObjectInfo().

C++ documentation:

Dumps information about signal connections, etc. for this object to the debug output.

Note: before Qt 5.9, this function was not const.

See also dumpObjectTree().

Source

pub unsafe fn dump_object_info(&self)

Dumps information about signal connections, etc. for this object to the debug output.

Calls C++ function: void QObject::dumpObjectInfo() const.

C++ documentation:

Dumps information about signal connections, etc. for this object to the debug output.

Note: before Qt 5.9, this function was not const.

See also dumpObjectTree().

Source

pub unsafe fn dump_object_tree_mut(&self)

Dumps a tree of children to the debug output.

Calls C++ function: void QObject::dumpObjectTree().

C++ documentation:

Dumps a tree of children to the debug output.

Note: before Qt 5.9, this function was not const.

See also dumpObjectInfo().

Source

pub unsafe fn dump_object_tree(&self)

Dumps a tree of children to the debug output.

Calls C++ function: void QObject::dumpObjectTree() const.

C++ documentation:

Dumps a tree of children to the debug output.

Note: before Qt 5.9, this function was not const.

See also dumpObjectInfo().

Source

pub unsafe fn dynamic_property_names(&self) -> CppBox<QListOfQByteArray>

Returns the names of all properties that were dynamically added to the object using setProperty().

Calls C++ function: QList<QByteArray> QObject::dynamicPropertyNames() const.

C++ documentation:

Returns the names of all properties that were dynamically added to the object using setProperty().

This function was introduced in Qt 4.2.

Source

pub unsafe fn eq(&self, p: impl CastInto<Ref<QPointerOfQObject>>) -> bool

Returns true if c1 and c2 are the same Unicode character; otherwise returns false.

Calls C++ function: bool operator==(QObject* o, const QPointer<QObject>& p).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for bool operator==(QChar c1, QChar c2):

Returns true if c1 and c2 are the same Unicode character; otherwise returns false.

Source

pub unsafe fn event(&self, event: impl CastInto<Ptr<QEvent>>) -> bool

This virtual function receives events to an object and should return true if the event e was recognized and processed.

Calls C++ function: virtual bool QObject::event(QEvent* event).

C++ documentation:

This virtual function receives events to an object and should return true if the event e was recognized and processed.

The event() function can be reimplemented to customize the behavior of an object.

Make sure you call the parent event class implementation for all the events you did not handle.

Example:

class MyClass : public QWidget { Q_OBJECT

public: MyClass(QWidget *parent = 0); ~MyClass();

bool event(QEvent* ev) { if (ev->type() == QEvent::PolishRequest) { // overwrite handling of PolishRequest if any doThings(); return true; } else if (ev->type() == QEvent::Show) { // complement handling of Show if any doThings2(); QWidget::event(ev); return true; } // Make sure the rest of events are handled return QWidget::event(ev); } };

See also installEventFilter(), timerEvent(), QCoreApplication::sendEvent(), and QCoreApplication::postEvent().

Source

pub unsafe fn event_filter( &self, watched: impl CastInto<Ptr<QObject>>, event: impl CastInto<Ptr<QEvent>>, ) -> bool

Filters events if this object has been installed as an event filter for the watched object.

Calls C++ function: virtual bool QObject::eventFilter(QObject* watched, QEvent* event).

C++ documentation:

Filters events if this object has been installed as an event filter for the watched object.

In your reimplementation of this function, if you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.

Example:

class MainWindow : public QMainWindow { public: MainWindow();

protected: bool eventFilter(QObject obj, QEvent ev);

private: QTextEdit *textEdit; };

MainWindow::MainWindow() { textEdit = new QTextEdit; setCentralWidget(textEdit);

textEdit->installEventFilter(this); }

bool MainWindow::eventFilter(QObject obj, QEvent event) { if (obj == textEdit) { if (event->type() == QEvent::KeyPress) { QKeyEvent keyEvent = static_cast<QKeyEvent>(event); qDebug() << “Ate key press” << keyEvent->key(); return true; } else { return false; } } else { // pass the event on to the parent class return QMainWindow::eventFilter(obj, event); } }

Notice in the example above that unhandled events are passed to the base class's eventFilter() function, since the base class might have reimplemented eventFilter() for its own internal purposes.

Warning: If you delete the receiver object in this function, be sure to return true. Otherwise, Qt will forward the event to the deleted object and the program might crash.

See also installEventFilter().

Source

pub unsafe fn find_child_q_object_2a( &self, a_name: impl CastInto<Ref<QString>>, options: QFlags<FindChildOption>, ) -> QPtr<QObject>

Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

Calls C++ function: QObject* QObject::findChild<QObject*>(const QString& aName = …, QFlags<Qt::FindChildOption> options = …) const.

C++ documentation:

Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

If there is more than one child matching the search, the most direct ancestor is returned. If there are several direct ancestors, it is undefined which one will be returned. In that case, findChildren() should be used.

This example returns a child QPushButton of parentWidget named "button1", even if the button isn't a direct child of the parent:

QPushButton button = parentWidget->findChild<QPushButton >(“button1”);

This example returns a QListWidget child of parentWidget:

QListWidget list = parentWidget->findChild<QListWidget >();

This example returns a child QPushButton of parentWidget (its direct parent) named "button1":

QPushButton button = parentWidget->findChild<QPushButton >(“button1”, Qt::FindDirectChildrenOnly);

This example returns a QListWidget child of parentWidget, its direct parent:

QListWidget list = parentWidget->findChild<QListWidget >(QString(), Qt::FindDirectChildrenOnly);

See also findChildren().

Source

pub unsafe fn find_child_q_object_1a( &self, a_name: impl CastInto<Ref<QString>>, ) -> QPtr<QObject>

Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

Calls C++ function: QObject* QObject::findChild<QObject*>(const QString& aName = …) const.

C++ documentation:

Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

If there is more than one child matching the search, the most direct ancestor is returned. If there are several direct ancestors, it is undefined which one will be returned. In that case, findChildren() should be used.

This example returns a child QPushButton of parentWidget named "button1", even if the button isn't a direct child of the parent:

QPushButton button = parentWidget->findChild<QPushButton >(“button1”);

This example returns a QListWidget child of parentWidget:

QListWidget list = parentWidget->findChild<QListWidget >();

This example returns a child QPushButton of parentWidget (its direct parent) named "button1":

QPushButton button = parentWidget->findChild<QPushButton >(“button1”, Qt::FindDirectChildrenOnly);

This example returns a QListWidget child of parentWidget, its direct parent:

QListWidget list = parentWidget->findChild<QListWidget >(QString(), Qt::FindDirectChildrenOnly);

See also findChildren().

Source

pub unsafe fn find_child_q_object_0a(&self) -> QPtr<QObject>

Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

Calls C++ function: QObject* QObject::findChild<QObject*>() const.

C++ documentation:

Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

If there is more than one child matching the search, the most direct ancestor is returned. If there are several direct ancestors, it is undefined which one will be returned. In that case, findChildren() should be used.

This example returns a child QPushButton of parentWidget named "button1", even if the button isn't a direct child of the parent:

QPushButton button = parentWidget->findChild<QPushButton >(“button1”);

This example returns a QListWidget child of parentWidget:

QListWidget list = parentWidget->findChild<QListWidget >();

This example returns a child QPushButton of parentWidget (its direct parent) named "button1":

QPushButton button = parentWidget->findChild<QPushButton >(“button1”, Qt::FindDirectChildrenOnly);

This example returns a QListWidget child of parentWidget, its direct parent:

QListWidget list = parentWidget->findChild<QListWidget >(QString(), Qt::FindDirectChildrenOnly);

See also findChildren().

Source

pub unsafe fn find_children_q_object_q_string_q_flags_find_child_option( &self, a_name: impl CastInto<Ref<QString>>, options: QFlags<FindChildOption>, ) -> CppBox<QListOfQObject>

Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

Calls C++ function: QList<QObject*> QObject::findChildren<QObject*>(const QString& aName = …, QFlags<Qt::FindChildOption> options = …) const.

C++ documentation:

Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

The following example shows how to find a list of child QWidgets of the specified parentWidget named widgetname:

QList<QWidget > widgets = parentWidget.findChildren<QWidget >(“widgetname”);

This example returns all QPushButtons that are children of parentWidget:

QList<QPushButton > allPButtons = parentWidget.findChildren<QPushButton >();

This example returns all QPushButtons that are immediate children of parentWidget:

QList<QPushButton > childButtons = parentWidget.findChildren<QPushButton >(QString(), Qt::FindDirectChildrenOnly);

See also findChild().

Source

pub unsafe fn find_children_q_object_q_reg_exp_q_flags_find_child_option( &self, re: impl CastInto<Ref<QRegExp>>, options: QFlags<FindChildOption>, ) -> CppBox<QListOfQObject>

This function overloads findChildren().

Calls C++ function: QList<QObject*> QObject::findChildren<QObject*>(const QRegExp& re, QFlags<Qt::FindChildOption> options = …) const.

C++ documentation:

This function overloads findChildren().

Returns the children of this object that can be cast to type T and that have names matching the regular expression regExp, or an empty list if there are no such objects. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

Source

pub unsafe fn find_children_q_object_q_regular_expression_q_flags_find_child_option( &self, re: impl CastInto<Ref<QRegularExpression>>, options: QFlags<FindChildOption>, ) -> CppBox<QListOfQObject>

This function overloads findChildren().

Calls C++ function: QList<QObject*> QObject::findChildren<QObject*>(const QRegularExpression& re, QFlags<Qt::FindChildOption> options = …) const.

C++ documentation:

This function overloads findChildren().

Returns the children of this object that can be cast to type T and that have names matching the regular expression re, or an empty list if there are no such objects. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

This function was introduced in Qt 5.0.

Source

pub unsafe fn find_children_q_object_q_string( &self, a_name: impl CastInto<Ref<QString>>, ) -> CppBox<QListOfQObject>

Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

Calls C++ function: QList<QObject*> QObject::findChildren<QObject*>(const QString& aName = …) const.

C++ documentation:

Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

The following example shows how to find a list of child QWidgets of the specified parentWidget named widgetname:

QList<QWidget > widgets = parentWidget.findChildren<QWidget >(“widgetname”);

This example returns all QPushButtons that are children of parentWidget:

QList<QPushButton > allPButtons = parentWidget.findChildren<QPushButton >();

This example returns all QPushButtons that are immediate children of parentWidget:

QList<QPushButton > childButtons = parentWidget.findChildren<QPushButton >(QString(), Qt::FindDirectChildrenOnly);

See also findChild().

Source

pub unsafe fn find_children_q_object(&self) -> CppBox<QListOfQObject>

Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

Calls C++ function: QList<QObject*> QObject::findChildren<QObject*>() const.

C++ documentation:

Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

The following example shows how to find a list of child QWidgets of the specified parentWidget named widgetname:

QList<QWidget > widgets = parentWidget.findChildren<QWidget >(“widgetname”);

This example returns all QPushButtons that are children of parentWidget:

QList<QPushButton > allPButtons = parentWidget.findChildren<QPushButton >();

This example returns all QPushButtons that are immediate children of parentWidget:

QList<QPushButton > childButtons = parentWidget.findChildren<QPushButton >(QString(), Qt::FindDirectChildrenOnly);

See also findChild().

Source

pub unsafe fn find_children_q_object_q_reg_exp( &self, re: impl CastInto<Ref<QRegExp>>, ) -> CppBox<QListOfQObject>

This function overloads findChildren().

Calls C++ function: QList<QObject*> QObject::findChildren<QObject*>(const QRegExp& re) const.

C++ documentation:

This function overloads findChildren().

Returns the children of this object that can be cast to type T and that have names matching the regular expression regExp, or an empty list if there are no such objects. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

Source

pub unsafe fn find_children_q_object_q_regular_expression( &self, re: impl CastInto<Ref<QRegularExpression>>, ) -> CppBox<QListOfQObject>

This function overloads findChildren().

Calls C++ function: QList<QObject*> QObject::findChildren<QObject*>(const QRegularExpression& re) const.

C++ documentation:

This function overloads findChildren().

Returns the children of this object that can be cast to type T and that have names matching the regular expression re, or an empty list if there are no such objects. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

This function was introduced in Qt 5.0.

Source

pub unsafe fn inherits(&self, classname: *const i8) -> bool

Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false.

Calls C++ function: bool QObject::inherits(const char* classname) const.

C++ documentation:

Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false.

A class is considered to inherit itself.

Example:

QTimer *timer = new QTimer; // QTimer inherits QObject timer->inherits(“QTimer”); // returns true timer->inherits(“QObject”); // returns true timer->inherits(“QAbstractButton”); // returns false

// QVBoxLayout inherits QObject and QLayoutItem QVBoxLayout *layout = new QVBoxLayout; layout->inherits(“QObject”); // returns true layout->inherits(“QLayoutItem”); // returns true (even though QLayoutItem is not a QObject)

If you need to determine whether an object is an instance of a particular class for the purpose of casting it, consider using qobject_cast<Type *>(object) instead.

See also metaObject() and qobject_cast().

Source

pub unsafe fn install_event_filter( &self, filter_obj: impl CastInto<Ptr<QObject>>, )

Installs an event filter filterObj on this object. For example:

Calls C++ function: void QObject::installEventFilter(QObject* filterObj).

C++ documentation:

Installs an event filter filterObj on this object. For example:


  monitoredObj->installEventFilter(filterObj);

An event filter is an object that receives all events that are sent to this object. The filter can either stop the event or forward it to this object. The event filter filterObj receives events via its eventFilter() function. The eventFilter() function must return true if the event should be filtered, (i.e. stopped); otherwise it must return false.

If multiple event filters are installed on a single object, the filter that was installed last is activated first.

Here's a KeyPressEater class that eats the key presses of its monitored objects:

class KeyPressEater : public QObject { Q_OBJECT ...

protected: bool eventFilter(QObject obj, QEvent event); };

bool KeyPressEater::eventFilter(QObject obj, QEvent event) { if (event->type() == QEvent::KeyPress) { QKeyEvent keyEvent = static_cast<QKeyEvent >(event); qDebug(“Ate key press %d”, keyEvent->key()); return true; } else { // standard event processing return QObject::eventFilter(obj, event); } }

And here's how to install it on two widgets:

KeyPressEater keyPressEater = new KeyPressEater(this); QPushButton pushButton = new QPushButton(this); QListView *listView = new QListView(this);

pushButton->installEventFilter(keyPressEater); listView->installEventFilter(keyPressEater);

The QShortcut class, for example, uses this technique to intercept shortcut key presses.

Warning: If you delete the receiver object in your eventFilter() function, be sure to return true. If you return false, Qt sends the event to the deleted object and the program will crash.

Note that the filtering object must be in the same thread as this object. If filterObj is in a different thread, this function does nothing. If either filterObj or this object are moved to a different thread after calling this function, the event filter will not be called until both objects have the same thread affinity again (it is not removed).

See also removeEventFilter(), eventFilter(), and event().

Source

pub unsafe fn is_widget_type(&self) -> bool

Returns true if the object is a widget; otherwise returns false.

Calls C++ function: bool QObject::isWidgetType() const.

C++ documentation:

Returns true if the object is a widget; otherwise returns false.

Calling this function is equivalent to calling inherits("QWidget"), except that it is much faster.

Source

pub unsafe fn is_window_type(&self) -> bool

Returns true if the object is a window; otherwise returns false.

Calls C++ function: bool QObject::isWindowType() const.

C++ documentation:

Returns true if the object is a window; otherwise returns false.

Calling this function is equivalent to calling inherits("QWindow"), except that it is much faster.

Source

pub unsafe fn kill_timer(&self, id: i32)

Kills the timer with timer identifier, id.

Calls C++ function: void QObject::killTimer(int id).

C++ documentation:

Kills the timer with timer identifier, id.

The timer identifier is returned by startTimer() when a timer event is started.

See also timerEvent() and startTimer().

Source

pub unsafe fn meta_object(&self) -> Ptr<QMetaObject>

Returns a pointer to the meta-object of this object.

Calls C++ function: virtual const QMetaObject* QObject::metaObject() const.

C++ documentation:

Returns a pointer to the meta-object of this object.

A meta-object contains information about a class that inherits QObject, e.g. class name, superclass name, properties, signals and slots. Every QObject subclass that contains the Q_OBJECT macro will have a meta-object.

The meta-object information is required by the signal/slot connection mechanism and the property system. The inherits() function also makes use of the meta-object.

If you have no pointer to an actual object instance but still want to access the meta-object of a class, you can use staticMetaObject.

Example:

QObject *obj = new QPushButton; obj->metaObject()->className(); // returns “QPushButton”

QPushButton::staticMetaObject.className(); // returns “QPushButton”

See also staticMetaObject.

Source

pub unsafe fn move_to_thread(&self, thread: impl CastInto<Ptr<QThread>>)

Changes the thread affinity for this object and its children. The object cannot be moved if it has a parent. Event processing will continue in the targetThread.

Calls C++ function: void QObject::moveToThread(QThread* thread).

C++ documentation:

Changes the thread affinity for this object and its children. The object cannot be moved if it has a parent. Event processing will continue in the targetThread.

To move an object to the main thread, use QApplication::instance() to retrieve a pointer to the current application, and then use QApplication::thread() to retrieve the thread in which the application lives. For example:

myObject->moveToThread(QApplication::instance()->thread());

If targetThread is zero, all event processing for this object and its children stops.

Note that all active timers for the object will be reset. The timers are first stopped in the current thread and restarted (with the same interval) in the targetThread. As a result, constantly moving an object between threads can postpone timer events indefinitely.

A QEvent::ThreadChange event is sent to this object just before the thread affinity is changed. You can handle this event to perform any special processing. Note that any new events that are posted to this object will be handled in the targetThread.

Warning: This function is not thread-safe; the current thread must be same as the current thread affinity. In other words, this function can only "push" an object from the current thread to another thread, it cannot "pull" an object from any arbitrary thread to the current thread.

See also thread().

Source

pub unsafe fn object_name(&self) -> CppBox<QString>

This property holds the name of this object

Calls C++ function: QString QObject::objectName() const.

C++ documentation:

This property holds the name of this object

You can find an object by name (and type) using findChild(). You can find a set of objects with findChildren().

qDebug(“MyClass::setPrecision(): (%s) invalid precision %f”, qPrintable(objectName()), newPrecision);

By default, this property contains an empty string.

Access functions:

QString objectName() const
void setObjectName(const QString &name)

Notifier signal:

void objectNameChanged(const QString &objectName)[see note below]

Note: This is a private signal. It can be used in signal connections but cannot be emitted by the user.

See also metaObject() and QMetaObject::className().

Source

pub unsafe fn parent(&self) -> QPtr<QObject>

Returns a pointer to the parent object.

Calls C++ function: QObject* QObject::parent() const.

C++ documentation:

Returns a pointer to the parent object.

See also setParent() and children().

Source

pub unsafe fn property(&self, name: *const i8) -> CppBox<QVariant>

Returns the value of the object's name property.

Calls C++ function: QVariant QObject::property(const char* name) const.

C++ documentation:

Returns the value of the object’s name property.

If no such property exists, the returned variant is invalid.

Information about all available properties is provided through the metaObject() and dynamicPropertyNames().

See also setProperty(), QVariant::isValid(), metaObject(), and dynamicPropertyNames().

Source

pub unsafe fn qt_metacall( &self, arg1: Call, arg2: i32, arg3: *mut *mut c_void, ) -> i32

Calls C++ function: virtual int QObject::qt_metacall(QMetaObject::Call arg1, int arg2, void** arg3).

Source

pub unsafe fn qt_metacast(&self, arg1: *const i8) -> *mut c_void

Calls C++ function: virtual void* QObject::qt_metacast(const char* arg1).

Source

pub unsafe fn remove_event_filter(&self, obj: impl CastInto<Ptr<QObject>>)

Removes an event filter object obj from this object. The request is ignored if such an event filter has not been installed.

Calls C++ function: void QObject::removeEventFilter(QObject* obj).

C++ documentation:

Removes an event filter object obj from this object. The request is ignored if such an event filter has not been installed.

All event filters for this object are automatically removed when this object is destroyed.

It is always safe to remove an event filter, even during event filter activation (i.e. from the eventFilter() function).

See also installEventFilter(), eventFilter(), and event().

Source

pub unsafe fn set_object_name(&self, name: impl CastInto<Ref<QString>>)

This property holds the name of this object

Calls C++ function: void QObject::setObjectName(const QString& name).

C++ documentation:

This property holds the name of this object

You can find an object by name (and type) using findChild(). You can find a set of objects with findChildren().

qDebug(“MyClass::setPrecision(): (%s) invalid precision %f”, qPrintable(objectName()), newPrecision);

By default, this property contains an empty string.

Access functions:

QString objectName() const
void setObjectName(const QString &name)

Notifier signal:

void objectNameChanged(const QString &objectName)[see note below]

Note: This is a private signal. It can be used in signal connections but cannot be emitted by the user.

See also metaObject() and QMetaObject::className().

Source

pub unsafe fn set_parent(&self, parent: impl CastInto<Ptr<QObject>>)

Makes the object a child of parent.

Calls C++ function: void QObject::setParent(QObject* parent).

C++ documentation:

Makes the object a child of parent.

See also parent() and children().

Source

pub unsafe fn set_property( &self, name: *const i8, value: impl CastInto<Ref<QVariant>>, ) -> bool

Sets the value of the object's name property to value.

Calls C++ function: bool QObject::setProperty(const char* name, const QVariant& value).

C++ documentation:

Sets the value of the object’s name property to value.

If the property is defined in the class using Q_PROPERTY then true is returned on success and false otherwise. If the property is not defined using Q_PROPERTY, and therefore not listed in the meta-object, it is added as a dynamic property and false is returned.

Information about all available properties is provided through the metaObject() and dynamicPropertyNames().

Dynamic properties can be queried again using property() and can be removed by setting the property value to an invalid QVariant. Changing the value of a dynamic property causes a QDynamicPropertyChangeEvent to be sent to the object.

Note: Dynamic properties starting with "_q_" are reserved for internal purposes.

See also property(), metaObject(), dynamicPropertyNames(), and QMetaProperty::write().

Source

pub unsafe fn signals_blocked(&self) -> bool

Returns true if signals are blocked; otherwise returns false.

Calls C++ function: bool QObject::signalsBlocked() const.

C++ documentation:

Returns true if signals are blocked; otherwise returns false.

Signals are not blocked by default.

See also blockSignals() and QSignalBlocker.

Source

pub unsafe fn start_timer_2a(&self, interval: i32, timer_type: TimerType) -> i32

Starts a timer and returns a timer identifier, or returns zero if it could not start a timer.

Calls C++ function: int QObject::startTimer(int interval, Qt::TimerType timerType = …).

C++ documentation:

Starts a timer and returns a timer identifier, or returns zero if it could not start a timer.

A timer event will occur every interval milliseconds until killTimer() is called. If interval is 0, then the timer event occurs once every time there are no more window system events to process.

The virtual timerEvent() function is called with the QTimerEvent event parameter class when a timer event occurs. Reimplement this function to get timer events.

If multiple timers are running, the QTimerEvent::timerId() can be used to find out which timer was activated.

Example:

class MyObject : public QObject { Q_OBJECT

public: MyObject(QObject *parent = 0);

protected: void timerEvent(QTimerEvent *event); };

MyObject::MyObject(QObject *parent) : QObject(parent) { startTimer(50); // 50-millisecond timer startTimer(1000); // 1-second timer startTimer(60000); // 1-minute timer

using namespace std::chrono; startTimer(milliseconds(50)); startTimer(seconds(1)); startTimer(minutes(1));

// since C++14 we can use std::chrono::duration literals, e.g.: startTimer(100ms); startTimer(5s); startTimer(2min); startTimer(1h); }

void MyObject::timerEvent(QTimerEvent *event) { qDebug() << “Timer ID:” << event->timerId(); }

Note that QTimer's accuracy depends on the underlying operating system and hardware. The timerType argument allows you to customize the accuracy of the timer. See Qt::TimerType for information on the different timer types. Most platforms support an accuracy of 20 milliseconds; some provide more. If Qt is unable to deliver the requested number of timer events, it will silently discard some.

The QTimer class provides a high-level programming interface with single-shot timers and timer signals instead of events. There is also a QBasicTimer class that is more lightweight than QTimer and less clumsy than using timer IDs directly.

See also timerEvent(), killTimer(), and QTimer::singleShot().

Source

pub unsafe fn start_timer_1a(&self, interval: i32) -> i32

Starts a timer and returns a timer identifier, or returns zero if it could not start a timer.

Calls C++ function: int QObject::startTimer(int interval).

C++ documentation:

Starts a timer and returns a timer identifier, or returns zero if it could not start a timer.

A timer event will occur every interval milliseconds until killTimer() is called. If interval is 0, then the timer event occurs once every time there are no more window system events to process.

The virtual timerEvent() function is called with the QTimerEvent event parameter class when a timer event occurs. Reimplement this function to get timer events.

If multiple timers are running, the QTimerEvent::timerId() can be used to find out which timer was activated.

Example:

class MyObject : public QObject { Q_OBJECT

public: MyObject(QObject *parent = 0);

protected: void timerEvent(QTimerEvent *event); };

MyObject::MyObject(QObject *parent) : QObject(parent) { startTimer(50); // 50-millisecond timer startTimer(1000); // 1-second timer startTimer(60000); // 1-minute timer

using namespace std::chrono; startTimer(milliseconds(50)); startTimer(seconds(1)); startTimer(minutes(1));

// since C++14 we can use std::chrono::duration literals, e.g.: startTimer(100ms); startTimer(5s); startTimer(2min); startTimer(1h); }

void MyObject::timerEvent(QTimerEvent *event) { qDebug() << “Timer ID:” << event->timerId(); }

Note that QTimer's accuracy depends on the underlying operating system and hardware. The timerType argument allows you to customize the accuracy of the timer. See Qt::TimerType for information on the different timer types. Most platforms support an accuracy of 20 milliseconds; some provide more. If Qt is unable to deliver the requested number of timer events, it will silently discard some.

The QTimer class provides a high-level programming interface with single-shot timers and timer signals instead of events. There is also a QBasicTimer class that is more lightweight than QTimer and less clumsy than using timer IDs directly.

See also timerEvent(), killTimer(), and QTimer::singleShot().

Source

pub unsafe fn thread(&self) -> QPtr<QThread>

Returns the thread in which the object lives.

Calls C++ function: QThread* QObject::thread() const.

C++ documentation:

Returns the thread in which the object lives.

See also moveToThread().

Trait Implementations§

Source§

impl CppDeletable for QGraphicsScene

Source§

unsafe fn delete(&self)

Removes and deletes all items from the scene object before destroying the scene object. The scene object is removed from the application's global scene list, and it is removed from all associated views.

Calls C++ function: virtual [destructor] void QGraphicsScene::~QGraphicsScene().

C++ documentation:

Removes and deletes all items from the scene object before destroying the scene object. The scene object is removed from the application’s global scene list, and it is removed from all associated views.

Source§

impl Deref for QGraphicsScene

Source§

fn deref(&self) -> &QObject

Calls C++ function: QObject* static_cast<QObject*>(QGraphicsScene* ptr).

Source§

type Target = QObject

The resulting type after dereferencing.
Source§

impl DynamicCast<QGraphicsScene> for QObject

Source§

unsafe fn dynamic_cast(ptr: Ptr<QObject>) -> Ptr<QGraphicsScene>

Calls C++ function: QGraphicsScene* dynamic_cast<QGraphicsScene*>(QObject* ptr).

Source§

impl StaticDowncast<QGraphicsScene> for QObject

Source§

unsafe fn static_downcast(ptr: Ptr<QObject>) -> Ptr<QGraphicsScene>

Calls C++ function: QGraphicsScene* static_cast<QGraphicsScene*>(QObject* ptr).

Source§

impl StaticUpcast<QObject> for QGraphicsScene

Source§

unsafe fn static_upcast(ptr: Ptr<QGraphicsScene>) -> Ptr<QObject>

Calls C++ function: QObject* static_cast<QObject*>(QGraphicsScene* ptr).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

Source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> StaticUpcast<T> for T

Source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.