本文整理汇总了C++中QPinchGesture::d_func方法的典型用法代码示例。如果您正苦于以下问题:C++ QPinchGesture::d_func方法的具体用法?C++ QPinchGesture::d_func怎么用?C++ QPinchGesture::d_func使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPinchGesture
的用法示例。
在下文中一共展示了QPinchGesture::d_func方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reset
void QPinchGestureRecognizer::reset(QGesture *state)
{
QPinchGesture *pinch = static_cast<QPinchGesture *>(state);
QPinchGesturePrivate *d = pinch->d_func();
d->totalChangeFlags = d->changeFlags = 0;
d->startCenterPoint = d->lastCenterPoint = d->centerPoint = QPointF();
d->totalScaleFactor = d->lastScaleFactor = d->scaleFactor = 1;
d->totalRotationAngle = d->lastRotationAngle = d->rotationAngle = 0;
d->isNewSequence = true;
d->startPosition[0] = d->startPosition[1] = QPointF();
QGestureRecognizer::reset(state);
}
示例2: recognize
QGestureRecognizer::Result QPinchGestureRecognizer::recognize(QGesture *state,
QObject *,
QEvent *event)
{
QPinchGesture *q = static_cast<QPinchGesture *>(state);
QPinchGesturePrivate *d = q->d_func();
const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
QGestureRecognizer::Result result;
switch (event->type()) {
case QEvent::TouchBegin: {
result = QGestureRecognizer::MayBeGesture;
break;
}
case QEvent::TouchEnd: {
if (q->state() != Qt::NoGesture) {
result = QGestureRecognizer::FinishGesture;
} else {
result = QGestureRecognizer::CancelGesture;
}
break;
}
case QEvent::TouchUpdate: {
d->changeFlags = 0;
if (ev->touchPoints().size() == 2) {
QTouchEvent::TouchPoint p1 = ev->touchPoints().at(0);
QTouchEvent::TouchPoint p2 = ev->touchPoints().at(1);
d->hotSpot = p1.screenPos();
d->isHotSpotSet = true;
QPointF centerPoint = (p1.screenPos() + p2.screenPos()) / 2.0;
if (d->isNewSequence) {
d->startPosition[0] = p1.screenPos();
d->startPosition[1] = p2.screenPos();
d->lastCenterPoint = centerPoint;
} else {
d->lastCenterPoint = d->centerPoint;
}
d->centerPoint = centerPoint;
d->changeFlags |= QPinchGesture::CenterPointChanged;
if (d->isNewSequence) {
d->scaleFactor = 1.0;
d->lastScaleFactor = 1.0;
} else {
d->lastScaleFactor = d->scaleFactor;
QLineF line(p1.screenPos(), p2.screenPos());
QLineF lastLine(p1.lastScreenPos(), p2.lastScreenPos());
d->scaleFactor = line.length() / lastLine.length();
}
d->totalScaleFactor = d->totalScaleFactor * d->scaleFactor;
d->changeFlags |= QPinchGesture::ScaleFactorChanged;
qreal angle = QLineF(p1.screenPos(), p2.screenPos()).angle();
if (angle > 180)
angle -= 360;
qreal startAngle = QLineF(p1.startScreenPos(), p2.startScreenPos()).angle();
if (startAngle > 180)
startAngle -= 360;
const qreal rotationAngle = startAngle - angle;
if (d->isNewSequence)
d->lastRotationAngle = 0.0;
else
d->lastRotationAngle = d->rotationAngle;
d->rotationAngle = rotationAngle;
d->totalRotationAngle += d->rotationAngle - d->lastRotationAngle;
d->changeFlags |= QPinchGesture::RotationAngleChanged;
d->totalChangeFlags |= d->changeFlags;
d->isNewSequence = false;
result = QGestureRecognizer::TriggerGesture;
} else {
d->isNewSequence = true;
if (q->state() == Qt::NoGesture)
result = QGestureRecognizer::Ignore;
else
result = QGestureRecognizer::FinishGesture;
}
break;
}
case QEvent::MouseButtonPress:
case QEvent::MouseMove:
case QEvent::MouseButtonRelease:
result = QGestureRecognizer::Ignore;
break;
default:
result = QGestureRecognizer::Ignore;
break;
}
return result;
}