QGraphicsObject 类

QGraphicsObject 类提供基类用于所有要求信号、槽及特性的图形项。 更多...

头: #include <QGraphicsObject>
CMake: find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(mytarget PRIVATE Qt6::Widgets)
qmake: QT += widgets
继承: QObject and QGraphicsItem
继承者:

QGraphicsSvgItem , QGraphicsTextItem ,和 QGraphicsWidget

特性

公共函数

QGraphicsObject (QGraphicsItem * parent = nullptr)
virtual ~QGraphicsObject ()
void grabGesture (Qt::GestureType gesture , Qt::GestureFlags flags = Qt::GestureFlags())
void ungrabGesture (Qt::GestureType gesture )

信号

void enabledChanged ()
void opacityChanged ()
void parentChanged ()
void rotationChanged ()
void scaleChanged ()
void visibleChanged ()
void xChanged ()
void yChanged ()
void zChanged ()

重实现保护函数

virtual bool event (QEvent * ev ) override

保护槽

void updateMicroFocus ()

详细描述

类延伸 QGraphicsItem with QObject 的信号/槽和特性机制。它映射了很多 QGraphicsItem 基本 setter 和 getter 特性并为其中很多添加了通知信号。

父级和子级

Each graphics object can be constructed with a parent item. This ensures that the item will be destroyed when its parent item is destroyed. Although QGraphicsObject inherits from both QObject and QGraphicsItem ,应使用函数提供通过 QGraphicsItem , not QObject , to manage the relationships between parent and child items.

The relationships between items can be explored using the parentItem () 和 childItems () functions. In the hierarchy of items in a scene, the parentObject () 和 parentWidget () functions are the equivalent of the QWidget::parent () 和 QWidget::parentWidget () functions for QWidget 子类。

另请参阅 QGraphicsWidget .

特性文档编制

effect : QGraphicsEffect * const

此特性保持附加到此项的效果

另请参阅 QGraphicsItem::setGraphicsEffect () 和 QGraphicsItem::graphicsEffect ().

enabled : const bool

This property holds whether the item is enabled or not

此特性的声明在 QGraphicsItem .

默认情况下,此特性为 true .

通知程序信号:

void enabledChanged ()

另请参阅 QGraphicsItem::isEnabled () 和 QGraphicsItem::setEnabled ().

opacity : const qreal

此特性保持项的不透明度

通知程序信号:

void opacityChanged ()

另请参阅 QGraphicsItem::setOpacity () 和 QGraphicsItem::opacity ().

parent : QGraphicsObject * const

This property holds the parent of the item

注意: The item's parent is set independently of the parent object returned by QObject::parent ().

通知程序信号:

void parentChanged ()

另请参阅 QGraphicsItem::setParentItem () 和 QGraphicsItem::parentObject ().

pos : const QPointF

此特性保持项的位置

另请参阅 QGraphicsItem::setPos () 和 QGraphicsItem::pos ().

rotation : const qreal

This property holds the rotation of the item in degrees.

This specifies how many degrees to rotate the item around its transformOrigin. The default rotation is 0 degrees (i.e. not rotated at all).

通知程序信号:

void rotationChanged ()

scale : const qreal

This property holds the scale of the item.

A scale of less than 1 means the item will be displayed smaller than normal, and a scale of greater than 1 means the item will be displayed larger than normal. A negative scale means the item will be mirrored.

By default, items are displayed at a scale of 1 (i.e. at their normal size).

Scaling is from the item's transformOrigin.

通知程序信号:

void scaleChanged ()

transformOriginPoint : const QPointF

This property holds the transformation origin

This property sets a specific point in the item's coordinate system as the origin for scale and rotation.

另请参阅 scale , rotation ,和 QGraphicsItem::transformOriginPoint ().

visible : const bool

This property holds whether the item is visible or not

此特性的声明在 QGraphicsItem .

默认情况下,此特性为 true .

通知程序信号:

void visibleChanged ()

另请参阅 QGraphicsItem::isVisible () 和 QGraphicsItem::setVisible ().

x : const qreal

This property holds the x position of the item

Describes the items x position.

通知程序信号:

void xChanged ()

另请参阅 QGraphicsItem::setX () 和 setPos ().

y : const qreal

This property holds the y position of the item

Describes the items y position.

通知程序信号:

void yChanged ()

另请参阅 QGraphicsItem::setY () 和 setPos ().

z : const qreal

This property holds the z value of the item

Describes the items z value.

通知程序信号:

void zChanged ()

另请参阅 QGraphicsItem::setZValue () 和 zValue ().

成员函数文档编制

[explicit] QGraphicsObject:: QGraphicsObject ( QGraphicsItem * parent = nullptr)

Constructs a QGraphicsObject with parent .

[virtual noexcept] QGraphicsObject:: ~QGraphicsObject ()

析构函数。

[signal] void QGraphicsObject:: enabledChanged ()

This signal gets emitted whenever the item gets enabled or disabled.

注意: 通知程序信号对于特性 enabled .

另请参阅 isEnabled ().

[override virtual protected] bool QGraphicsObject:: event ( QEvent * ev )

重实现: QObject::event (QEvent *e).

void QGraphicsObject:: grabGesture ( Qt::GestureType gesture , Qt::GestureFlags flags = Qt::GestureFlags())

Subscribes the graphics object to the given gesture 采有特定 flags .

另请参阅 ungrabGesture () 和 QGestureEvent .

[signal] void QGraphicsObject:: opacityChanged ()

This signal gets emitted whenever the opacity of the item changes

注意: 通知程序信号对于特性 opacity .

另请参阅 QGraphicsItem::opacity ().

[signal] void QGraphicsObject:: parentChanged ()

This signal gets emitted whenever the parent of the item changes

注意: 通知程序信号对于特性 parent .

[signal] void QGraphicsObject:: rotationChanged ()

This signal gets emitted whenever the rotation of the item changes.

注意: 通知程序信号对于特性 rotation .

[signal] void QGraphicsObject:: scaleChanged ()

This signal is emitted when the scale of the item changes.

注意: 通知程序信号对于特性 scale .

void QGraphicsObject:: ungrabGesture ( Qt::GestureType gesture )

Unsubscribes the graphics object from the given gesture .

另请参阅 grabGesture () 和 QGestureEvent .

[protected slot] void QGraphicsObject:: updateMicroFocus ()

Updates the item's micro focus. This is slot for convenience.

另请参阅 QInputMethod .

[signal] void QGraphicsObject:: visibleChanged ()

This signal gets emitted whenever the visibility of the item changes

注意: 通知程序信号对于特性 visible .

另请参阅 visible .

[signal] void QGraphicsObject:: xChanged ()

This signal gets emitted whenever the x position of the item changes

注意: 通知程序信号对于特性 x .

另请参阅 pos ().

[signal] void QGraphicsObject:: yChanged ()

This signal gets emitted whenever the y position of the item changes.

注意: 通知程序信号对于特性 y .

另请参阅 pos ().

[signal] void QGraphicsObject:: zChanged ()

This signal gets emitted whenever the z value of the item changes.

注意: 通知程序信号对于特性 z .

另请参阅 pos ().