文章目录
- 详述
- 属性
- **effect**: QGraphicsEffect* const
- **enabled**: const bool
- **opacity**: const qreal
- **parent**: QGraphicsObject* const
- **pos**: const QPointF
- **rotation**: const qreal
- **scale**: const qreal
- **transformOriginPoint**: const QPointF
- **visible**: const bool
- **x**: const qreal
- **y**: const qreal
- **z**: const qreal
- 公共类型
- 信号
- 重写的受保护的函数
- 受保护的槽函数
QGraphicsObject 类
QGraphicsObject类为需要信号,插槽和属性的所有图形项提供基类。
| Header: | #include < QGraphicsObject > |
|---|---|
| qmake: | QT += widgets |
| Inherits: | QObject and QGraphicsItem |
| Inherited By: | QGraphicsSvgItem, QGraphicsTextItem, and QGraphicsWidget |
| Since: | Qt 4.2 |

详述
该类使用QObject的信号/槽和属性机制扩展了QGraphicsItem。它将QGraphicsItem的许多基本setter和getter映射到属性,并为其中许多属性添加通知信号。
父子关系
每个图形对象都可以使用父项构造。 这样可以确保在销毁其父项时销毁该项。 尽管QGraphicsObject继承自QObject和QGraphicsItem,但是您应该使用QGraphicsItem提供的功能(而不是QObject)来管理父项和子项之间的关系。
可以使用parentItem() 和childItems() 函数探索项目之间的关系。 在场景中项目的层次结构中,parentObject() 和parentWidget() 函数等效于QWidget子类的QWidget::parent() 和QWidget::parentWidget() 函数。
另请参见QGraphicsWidget。
属性
effect: QGraphicsEffect* const
此属性保存附加到该项目的效果
参见QGraphicsItem::setGraphicsEffect()和QGraphicsItem::graphicsEffect()。
enabled: const bool
此属性保存是否启用该项目 此属性在QGraphicsItem中声明。默认情况下,此属性为true。
Notifier signal:
- void enabledChanged()
参见QGraphicsItem::isEnabled()和QGraphicsItem::setEnabled()。
opacity: const qreal
此属性保存该项的不透明度
Notifier signal:
- void opacityChanged()
参见QGraphicsItem::setOpacity()和QGraphicsItem::opacity()。
parent: QGraphicsObject* const
此属性保存该项的父项 注意:项目的父对象是独立于QObject::parent()返回的父对象设置的。
Notifier signal:
- void parentChanged()
参见QGraphicsItem::setParentItem()和QGraphicsItem::parentObject()。
pos: const QPointF
此属性保存项目的位置 描述项目的位置。
参见QGraphicsItem::setPos()和QGraphicsItem::pos()。
rotation: const qreal
此属性保存项目的旋转度(以度为单位)
这指定将项目围绕其transformOrigin旋转多少度。 默认旋转角度为0度(即完全不旋转)。
Notifier signal:
- void rotationChanged()
scale: const qreal
此属性保存项目的比例
比例小于1表示该项目将显示比正常小,比例尺大于1表示该项目将显示比正常大。 负比例表示该项目将被镜像。
默认情况下,项目以1的比例显示(即以其正常大小显示)。
缩放来自项目的transformOrigin。
Notifier signal:
- void scaleChanged()
transformOriginPoint: const QPointF
此属性保存转换原点
此属性在项目坐标系中设置一个特定点作为缩放和旋转的原点。
另请参见scale,rotation和QGraphicsItem::transformOriginPoint() 。
visible: const bool
此属性保存该项目是否可见
此属性在QGraphicsItem中声明。
默认情况下,此属性为true。
Notifier signal:
- void visibleChanged()
另请参见QGraphicsItem::isVisible() 和QGraphicsItem::setVisible() 。
x: const qreal
此属性保存项目的x位置 描述项目x位置。
Notifier signal:
- void xChanged()
另请参见QGraphicsItem::setX() 和setPos() 。
y: const qreal
该属性保持项目的y位置 描述项目y的位置。
Notifier signal:
- void yChanged()
另请参见QGraphicsItem::setY() 和setPos() 。
z: const qreal
此属性保存项目的z值 描述项目的z值。
Notifier signal:
- void zChanged()
另请参见QGraphicsItem::setZValue() 和zValue() 。
公共类型
构造析构
- 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()
本文详细介绍了QGraphicsObject类,它是所有需要信号、槽和属性的图形项的基础类。文章覆盖了该类的主要属性如effect、enabled、opacity等,并探讨了父子关系及各种通知信号。
3万+

被折叠的 条评论
为什么被折叠?



