本文整理汇总了C++中QPanGesture::setProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ QPanGesture::setProperty方法的具体用法?C++ QPanGesture::setProperty怎么用?C++ QPanGesture::setProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPanGesture
的用法示例。
在下文中一共展示了QPanGesture::setProperty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: recognize
QGestureRecognizer::Result MousePanGestureRecognizer::recognize(QGesture *state, QObject *, QEvent *event)
{
QPanGesture *g = static_cast<QPanGesture *>(state);
if (event->type() == QEvent::TouchBegin) {
// ignore the following mousepress event
g->setProperty("ignoreMousePress", QVariant::fromValue<bool>(true));
} else if (event->type() == QEvent::TouchEnd) {
g->setProperty("ignoreMousePress", QVariant::fromValue<bool>(false));
}
QMouseEvent *me = static_cast<QMouseEvent *>(event);
if (event->type() == QEvent::MouseButtonPress) {
if (g->property("ignoreMousePress").toBool())
return QGestureRecognizer::Ignore;
g->setHotSpot(me->globalPos());
g->setProperty("startPos", me->globalPos());
g->setProperty("pressed", QVariant::fromValue<bool>(true));
return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint;
} else if (event->type() == QEvent::MouseMove) {
if (g->property("pressed").toBool()) {
QPoint offset = me->globalPos() - g->property("startPos").toPoint();
g->setLastOffset(g->offset());
g->setOffset(QPointF(offset.x(), offset.y()));
return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint;
}
return QGestureRecognizer::CancelGesture;
} else if (event->type() == QEvent::MouseButtonRelease) {
if (g->property("pressed").toBool())
return QGestureRecognizer::FinishGesture | QGestureRecognizer::ConsumeEventHint;
}
return QGestureRecognizer::Ignore;
}
示例2: reset
void MousePanGestureRecognizer::reset(QGesture *state)
{
QPanGesture *g = static_cast<QPanGesture *>(state);
g->setLastOffset(QPointF());
g->setOffset(QPointF());
g->setAcceleration(0);
g->setProperty("startPos", QVariant());
g->setProperty("pressed", QVariant::fromValue<bool>(false));
QGestureRecognizer::reset(state);
}
示例3: recognize
QGestureRecognizer::Result MousePanGestureRecognizer::recognize(QGesture *state, QObject *, QEvent *event)
{
QPanGesture *g = static_cast<QPanGesture *>(state);
QPoint globalPos;
switch (event->type()) {
case QEvent::GraphicsSceneMousePress:
case QEvent::GraphicsSceneMouseDoubleClick:
case QEvent::GraphicsSceneMouseMove:
case QEvent::GraphicsSceneMouseRelease:
globalPos = static_cast<QGraphicsSceneMouseEvent *>(event)->screenPos();
break;
case QEvent::MouseButtonPress:
case QEvent::MouseMove:
case QEvent::MouseButtonRelease:
globalPos = static_cast<QMouseEvent *>(event)->globalPos();
break;
default:
break;
}
if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonDblClick
|| event->type() == QEvent::GraphicsSceneMousePress || event->type() == QEvent::GraphicsSceneMouseDoubleClick) {
g->setHotSpot(globalPos);
g->setProperty("startPos", globalPos);
g->setProperty("pressed", QVariant::fromValue<bool>(true));
return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint;
} else if (event->type() == QEvent::MouseMove || event->type() == QEvent::GraphicsSceneMouseMove) {
if (g->property("pressed").toBool()) {
QPoint offset = globalPos - g->property("startPos").toPoint();
g->setLastOffset(g->offset());
g->setOffset(QPointF(offset.x(), offset.y()));
return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint;
}
return QGestureRecognizer::CancelGesture;
} else if (event->type() == QEvent::MouseButtonRelease || event->type() == QEvent::GraphicsSceneMouseRelease) {
return QGestureRecognizer::FinishGesture | QGestureRecognizer::ConsumeEventHint;
}
return QGestureRecognizer::Ignore;
}