缓存能够用于元素的逻辑坐标系统,QGraphicsItem用一个可配置的大小/解决方案建立了屏幕以外的像素缓冲区,追求质量会典型地降低,取决于缓冲的分辨率和元素变换,可以调用setCacheMode()再次调整缓存的分辨率
项目选定状态改变,如果该项目当前是选定的,它将会选择。 itemChange返回新的选中状态
窗口是模态的,整个场景和块输入到所有面板。
这是个纯虚函数,定义了边界矩形尺寸
class SimpleItem : public QGraphicsItem
{
public:
QRectF boundingRect() const
{
qreal penWidth = 1;
return QRectF(-10 - penWidth / 2, -10 - penWidth / 2,
20 + penWidth, 20 + penWidth);
}
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget)
{
painter->drawRoundedRect(-10, -10, 20, 20, 5, 5);
}
};
boundingRegion(const QTransform &itemToDeviceTransform) constchildItems() const
返回孩子item的一个链表,这些items按照栈顺序排列,考虑了item的插入顺序和Z-values
childrenBoundingRect() const
返回这个item的所有子孙items的本地坐标系统轮廓矩形。这个矩形包括了这个item所有的子孙item,如果这个item不含有子孙item,这个函数将返回一个空的矩形。
clearFocus()
去除item的光标,如果原来有光标焦点,当焦点失去时候,事件focus out event会发送给这个item,提示他将会失去焦点。
clipPath() const
返回此项目的裁剪路径
collidesWithItem(const QGraphicsItem *other, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const
如果这个item和另一个item碰撞就返回真,mode是应用于其他item的,默认是Qt::IntersectsItemShape,如果其他的item和这个item相互影响或者包含,被包含于这个item的形状(详见Qt::ItemSelectionMode)
默认的函数是基于外形相互影响,它调用两个item的shape()函数,这将会花费很大时间,你可以在QgraphicsItem子类中重写这个函数,提供一个简单的算法。这样你可以使用自己item的一些参数,这样可以提高碰撞侦测的效果。例如,两个完全没有转换的圆item的碰撞可以通过对比他们的圆心位置和半径
collidesWithPath(const QPainterPath &path, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const
如果item按照path碰撞就返回真
collidingItems(Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const
返回碰撞列表,碰撞模式取决于mode
commonAncestorItem(const QGraphicsItem *other) const
返回item最近的祖先item,如果other为0,或者没有祖先item,就返回0
contains(const QPointF &point) const
如果item包含了点point就返回TRUE,否则返回FALSE,最常用的是在QgraphicsView中调用,来判断这个item是否在光标下面,如果要重写这个函数,那就尽可能的简单。默认的这个函数调用的shape()函数
deviceTransform(const QTransform &viewportTransform) const
返回item设备的转换矩阵,使用viewportTransform来从场景到设备影射坐标,这个矩阵可以用来从这个item本地坐标到视图口坐标系统映射坐标或者几何图形,如果要映射视图口坐标到本地坐标,首先应该转换返回的这个矩阵。
effectiveOpacity() const
返回item的有效透明度,这个数值在0.0~~1.0之间
ensureVisible(const QRectF &rect = QRectF(), int xmargin = 50, int ymargin = 50)
如果项目是场景,项目将会检查鼠标是否处在可见区域的外面并且根据检查的结果移动滚动文本区域
focusItem() const
如果子项具有获得焦点,将返回该项指针,否则返回0
grabKeyboard()
项目接收键盘事件,直到该项目不可见,从场景移除或删除该项
grabMouse()
项目接收鼠标事件,直到该项目不可见,从场景移除或删除该项
hasCursor() const
如果该项有一个光标设置返回真,否则为假,默认为假,cursor()返回标准的箭头光标
hasFocus() const
项目是活动的,返回真,否则为假
hide()
隐藏项目
installSceneEventFilter(QGraphicsItem *filterItem)
安装场景事件过滤器
isAncestorOf(const QGraphicsItem *child) const
如果项目有子项,返回真
isBlockedByModalPanel(QGraphicsItem **blockingPanel = Q_NULLPTR) const
如果项目被模态窗口阻挡,返回真
isClipped() const
如果项目被裁剪,返回真
isObscured(const QRectF &rect = QRectF()) const
如果被任何碰撞项上面的不透明的形状完全遮蔽该项,返回true
isObscuredBy(const QGraphicsItem *item) const
如果这个项目的包围矩形被项目的不透明的形状完全遮蔽,返回true
isPanel() const
如果项目是一个面板,返回真
isUnderMouse() const
如果光标在项目上,返回真
isVisibleTo(const QGraphicsItem *parent) const
如果项目是可见的,返回真
isWidget() const
如果项目是控件,返回真
isWindow() const
如果项目是QGraphicsWidget,返回真
itemTransform(const QGraphicsItem *other, bool *ok = Q_NULLPTR) const
返回QTarnsForm式地图坐标
mapFromItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
项目坐标转换,返回映射的坐标,如果item是0,那么返回和mapFromScene()一样
mapFromParent(qreal x, qreal y, qreal w, qreal h) const
这是个父坐标系统转换,返回映射的坐标
mapFromScene(qreal x, qreal y, qreal w, qreal h) const
转换为场景坐标系统,返回映射的坐标
mapRectFromItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
转换为项目矩形坐标,返回映射的矩形
mapRectFromParent(qreal x, qreal y, qreal w, qreal h) const
转换为父项目坐标系统,返回映射的矩形
mapRectFromScene(qreal x, qreal y, qreal w, qreal h) const
转换为场景坐标,返回映射的矩形
mapRectToItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
转换为项目矩形坐标,返回映射的矩形,如果项目是0,这个函数返回的是mapFromScene()相同
mapRectToParent(qreal x, qreal y, qreal w, qreal h) const
转换为父项目坐标系统,返回映射的矩形
mapRectToScene(qreal x, qreal y, qreal w, qreal h) const
转换为场景坐标,返回映射的矩形
mapToItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
转换为项目坐标,返回映射的坐标
mapToParent(qreal x, qreal y, qreal w, qreal h) const
转换为父项坐标,返回映射的坐标
mapToScene(qreal x, qreal y, qreal w, qreal h) const
转换为场景坐标,返回映射的坐标
moveBy(qreal dx, qreal dy)
相对移动
opaqueArea() const
返回不透明形状区域,默认将返回一个空QPainterPath
panel() const
如果该项是面板,返回自身,否则如果父项是面板将返回父项,否则返回0
parentObject() const
如果父项不是QGraphicsObject,返回0,否则返回父项
parentWidget() const
返回父项控件
removeSceneEventFilter(QGraphicsItem *filterItem)
移除场景事件过滤器
resetTransform()
重置变换矩阵
rotation() const
返回顺时针旋转角度
scene() const
返回项目的当前场景
sceneBoundingRect() const
返回项目的场景的矩形
scenePos() const
返回项目在场景的位置
sceneTransform() const
返回这个项目的场景转换矩阵
scroll(qreal dx, qreal dy, const QRectF &rect = QRectF())
滚动项目,滚动比重绘快
setAcceptDrops(bool on)
设置接受拖放
setAcceptHoverEvents(bool enabled)
设置接受悬停事件
setAcceptTouchEvents(bool enabled)
设置接受触摸事件
setAcceptedMouseButtons(Qt::MouseButtons buttons)
设置该项目接受鼠标事件的鼠标按钮
setActive(bool active)
设置项目是否活动
setBoundingRegionGranularity(qreal granularity)
调节轮廓区域的粒度,默认的粒度是0,这时候item的区域和轮廓矩形一样的
setCacheMode(CacheMode mode, const QSize &logicalCacheSize = QSize())
设置缓存模式
setCursor(const QCursor &cursor)
设置光标形状
setData(int key, const QVariant &value)
设置自定义数据
setEnabled(bool enabled)
设置启用项目
setFiltersChildEvents(bool enabled)
设置过滤子项事件
setFlag(GraphicsItemFlag flag, bool enabled = true)
设置标志
setFlags(GraphicsItemFlags flags)
设置所有标志
setFocus(Qt::FocusReason focusReason = Qt::OtherFocusReason)
设置焦点
setFocusProxy(QGraphicsItem *item)
将该项目设置为焦点代理
setGraphicsEffect(QGraphicsEffect *effect)
设置效果
setGroup(QGraphicsItemGroup *group)
设置项目组
setInputMethodHints(Qt::InputMethodHints hints)
设置此项当前输入方法提示
setOpacity(qreal opacity)
设置不透明度
setPanelModality(PanelModality panelModality)
设置面板模式
setParentItem(QGraphicsItem *newParent)
设置父项
setPos(const QPointF &pos)
设置位置
setRotation(qreal angle)
设置旋转角度
setScale(qreal factor)
设置场景
setSelected(bool selected)
设置选择
setToolTip(const QString &toolTip)
设置提示
setTransform(const QTransform &matrix, bool combine = false)
设置变换
setTransformOriginPoint(qreal x, qreal y)
设置变换原点
setTransformations(const QList
设置旋转列表
setVisible(bool visible)
设置可见
setX(qreal x)
setY(qreal y)
设置坐标
setZValue(qreal z)
设置Z值
shape() const
返回形状,用于碰撞检测,命中测试等,默认返回矩形
show()
显示
stackBefore(const QGraphicsItem *sibling)
堆叠兄弟项目,项目必须是兄弟项
toGraphicsObject() const
返回转换为QGraphicsObject,如果本来是图像对象,返回0
最低项目类型值
mousePressEvent(QGraphicsSceneMouseEvent *event)
鼠标单击事件
mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
鼠标是否事件
prepareGeometryChange()
改变包围矩形
sceneEvent(QEvent *event)
场景事件
sceneEventFilter(QGraphicsItem *watched, QEvent *event)
场景事件过滤
updateMicroFocus()
焦点更新
wheelEvent(QGraphicsSceneWheelEvent *event)
滚轮事件
qgraphicsitem_cast(QGraphicsItem *item)
返回给定项目类型
英语渣渣必有错误,如有发现,欢迎留言