本文整理汇总了C++中QDeclarativeItem::keepMouseGrab方法的典型用法代码示例。如果您正苦于以下问题:C++ QDeclarativeItem::keepMouseGrab方法的具体用法?C++ QDeclarativeItem::keepMouseGrab怎么用?C++ QDeclarativeItem::keepMouseGrab使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDeclarativeItem
的用法示例。
在下文中一共展示了QDeclarativeItem::keepMouseGrab方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sendMouseEvent
bool QDeclarativeMouseArea::sendMouseEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QDeclarativeMouseArea);
QGraphicsSceneMouseEvent mouseEvent(event->type());
QRectF myRect = mapToScene(QRectF(0, 0, width(), height())).boundingRect();
QGraphicsScene *s = scene();
QDeclarativeItem *grabber = s ? qobject_cast<QDeclarativeItem*>(s->mouseGrabberItem()) : 0;
bool stealThisEvent = d->stealMouse;
if ((stealThisEvent || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab())) {
mouseEvent.setAccepted(false);
for (int i = 0x1; i <= 0x10; i <<= 1) {
if (event->buttons() & i) {
Qt::MouseButton button = Qt::MouseButton(i);
mouseEvent.setButtonDownPos(button, mapFromScene(event->buttonDownPos(button)));
}
}
mouseEvent.setScenePos(event->scenePos());
mouseEvent.setLastScenePos(event->lastScenePos());
mouseEvent.setPos(mapFromScene(event->scenePos()));
mouseEvent.setLastPos(mapFromScene(event->lastScenePos()));
switch(mouseEvent.type()) {
case QEvent::GraphicsSceneMouseMove:
mouseMoveEvent(&mouseEvent);
break;
case QEvent::GraphicsSceneMousePress:
mousePressEvent(&mouseEvent);
break;
case QEvent::GraphicsSceneMouseRelease:
mouseReleaseEvent(&mouseEvent);
break;
default:
break;
}
grabber = qobject_cast<QDeclarativeItem*>(s->mouseGrabberItem());
if (grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this)
grabMouse();
return stealThisEvent;
}
if (mouseEvent.type() == QEvent::GraphicsSceneMouseRelease) {
if (d->pressed) {
d->pressed = false;
d->stealMouse = false;
if (s && s->mouseGrabberItem() == this)
ungrabMouse();
emit canceled();
emit pressedChanged();
if (d->hovered) {
d->hovered = false;
emit hoveredChanged();
}
}
}
return false;
}