本文整理汇总了C++中qtouchevent::TouchPoint::screenPos方法的典型用法代码示例。如果您正苦于以下问题:C++ TouchPoint::screenPos方法的具体用法?C++ TouchPoint::screenPos怎么用?C++ TouchPoint::screenPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtouchevent::TouchPoint
的用法示例。
在下文中一共展示了TouchPoint::screenPos方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
bool QtPinchGestureRecognizer::update(const QTouchEvent::TouchPoint& point1, const QTouchEvent::TouchPoint& point2)
{
const qreal currentFingerDistance = QLineF(point1.screenPos(), point2.screenPos()).length();
switch (m_state) {
case NoGesture:
m_initialFingerDistance = currentFingerDistance;
m_state = GestureRecognitionStarted;
return false;
case GestureRecognitionStarted: {
const qreal pinchDistance = qAbs(currentFingerDistance - m_initialFingerDistance);
if (pinchDistance < pinchInitialTriggerDistanceThreshold)
return false;
m_state = GestureRecognized;
if (viewportController())
viewportController()->pinchGestureStarted(computePinchCenter(point1, point2));
// We reset the initial span distance to the current distance of the
// touch points in order to avoid the jump caused by the events which
// were skipped between the recognition start and the actual recognition.
m_initialFingerDistance = currentFingerDistance;
// fall through
}
case GestureRecognized:
const qreal totalScaleFactor = currentFingerDistance / m_initialFingerDistance;
const QPointF touchCenterInViewCoordinates = computePinchCenter(point1, point2);
if (viewportController())
viewportController()->pinchGestureRequestUpdate(touchCenterInViewCoordinates, totalScaleFactor);
return true;
break;
}
ASSERT_NOT_REACHED();
return false;
}
示例2: sceneEvent
bool PuzzleBoardItem::sceneEvent(QEvent *event)
{
if (event->type() == QEvent::TouchBegin || event->type() == QEvent::TouchUpdate || event->type() == QEvent::TouchEnd)
{
QTouchEvent *te = static_cast<QTouchEvent*>(event);
if (te->touchPoints().count() == 1)
{
QTouchEvent::TouchPoint tp = te->touchPoints().first();
QPointF diff = tp.screenPos() - this->game()->rotationGuideCoordinates();
if (abs(diff.x()) < 32 && abs(diff.y()) < 32)
{
event->ignore();
return false;
}
}
event->accept();
_game->handleTouchEvent(te);
if (!_autoRepainter->isActive())
update();
return true;
}
return QDeclarativeItem::sceneEvent(event);
}
示例3: if
bool gpsp4Qt::event(QEvent *event)
{
switch (event->type())
{
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
{
QList<QTouchEvent::TouchPoint> touchPoints = (static_cast<QTouchEvent*>(event))->touchPoints();
m_softKeys = 0;
for ( int i = 0; i < touchPoints.length(); i++ )
{
QTouchEvent::TouchPoint tp = touchPoints[i];
if ( tp.state() == Qt::TouchPointPressed || tp.state() == Qt::TouchPointMoved || tp.state() == Qt::TouchPointStationary)
{
if ( tp.screenPos().x() < DPAD_WIDTH )
{
m_softKeys |= m_dpad->getGpspKeys(tp.screenPos().x(), tp.screenPos().y());
}
else if ( tp.screenPos().x() > BUTTON_LEFT_POS )
{
m_softKeys |= m_rightButtons->getGpspKeys(tp.screenPos().x() - BUTTON_LEFT_POS, tp.screenPos().y());
}
}
}
event->accept();
return true;
}
case QEvent::TouchEnd:
{
m_softKeys = 0;
break;
}
case QEvent::FocusOut:
{
showAntSnesMenu();
}
default:
break;
}
return QWidget::event(event);
}
示例4: createWebGestureEvent
WebGestureEvent WebEventFactory::createWebGestureEvent(const QTouchEvent::TouchPoint& point, const WebEvent::Type& gestureType, const QTransform& fromItemTransform)
{
WebEvent::Type type = gestureType;
IntPoint position = fromItemTransform.map(point.pos()).toPoint();
IntPoint screenPosition = point.screenPos().toPoint();
WebEvent::Modifiers modifiers = WebEvent::Modifiers(0);
double timestamp = 0;
IntSize area = IntSize(point.rect().size().toSize());
FloatPoint delta = FloatPoint(0, 0);
return WebGestureEvent(type, position, screenPosition, modifiers, timestamp, area, delta);
}
示例5: switch
PlatformTouchPoint::PlatformTouchPoint(const QTouchEvent::TouchPoint& point)
{
// The QTouchEvent::TouchPoint API states that ids will be >= 0.
m_id = static_cast<unsigned>(point.id());
switch (point.state()) {
case Qt::TouchPointReleased: m_state = TouchReleased; break;
case Qt::TouchPointMoved: m_state = TouchMoved; break;
case Qt::TouchPointPressed: m_state = TouchPressed; break;
case Qt::TouchPointStationary: m_state = TouchStationary; break;
}
m_screenPos = point.screenPos().toPoint();
m_pos = point.pos().toPoint();
}
示例6:
PlatformTouchPoint::PlatformTouchPoint(const QTouchEvent::TouchPoint& point, State state)
// The QTouchEvent::TouchPoint API states that ids will be >= 0.
: m_id(point.id())
, m_state(state)
, m_screenPos(point.screenPos().toPoint())
, m_pos(point.pos().toPoint())
{
// Qt reports touch point size as rectangles, but we will pretend it is an oval.
QRect touchRect = point.rect().toAlignedRect();
if (touchRect.isValid()) {
m_radiusX = point.rect().width() / 2;
m_radiusY = point.rect().height() / 2;
} else {
// http://www.w3.org/TR/2011/WD-touch-events-20110505: 1 if no value is known.
m_radiusX = 1;
m_radiusY = 1;
}
m_force = point.pressure();
// FIXME: Support m_rotationAngle if QTouchEvent at some point supports it.
}
示例7: recognize
QGestureRecognizer::Result QTapGestureRecognizer::recognize(QGesture *state,
QObject *,
QEvent *event)
{
QTapGesture *q = static_cast<QTapGesture *>(state);
QTapGesturePrivate *d = q->d_func();
const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
QGestureRecognizer::Result result = QGestureRecognizer::CancelGesture;
switch (event->type()) {
case QEvent::TouchBegin: {
#ifndef QT_WEBOS // REBASE_CHECK_REQUIRED necessary?
d->position = ev->touchPoints().at(0).pos();
q->setHotSpot(ev->touchPoints().at(0).screenPos());
#else // QT_WEBOS
QTouchEvent::TouchPoint p = ev->touchPoints().at(0);
d->position = p.pos();
d->hotSpot = p.screenPos();
d->isHotSpotSet = true;
#endif // QT_WEBOS
result = QGestureRecognizer::TriggerGesture;
break;
}
case QEvent::TouchUpdate:
case QEvent::TouchEnd: {
if (q->state() != Qt::NoGesture && ev->touchPoints().size() == 1) {
QTouchEvent::TouchPoint p = ev->touchPoints().at(0);
#ifdef QT_WEBOS // REBASE_CHECK_REQUIRED use setHotSpot?
d->hotSpot = p.screenPos();
d->isHotSpotSet = true;
#endif // QT_WEBOS
QPoint delta = p.pos().toPoint() - p.startPos().toPoint();
enum { TapRadius = 40 };
if (delta.manhattanLength() <= TapRadius) {
if (event->type() == QEvent::TouchEnd)
result = QGestureRecognizer::FinishGesture;
else
result = QGestureRecognizer::TriggerGesture;
}
}
break;
}
case QEvent::MouseButtonPress:
case QEvent::MouseMove:
case QEvent::MouseButtonRelease:
result = QGestureRecognizer::Ignore;
break;
#ifdef QT_WEBOS
case QEvent::Gesture:
{
QGesture* g = static_cast<QGestureEvent*>(event)->gesture(Qt::SysMgrGestureFlick);
if (g && g->state() == Qt::GestureFinished && q->state() != Qt::NoGesture ) {
result = QGestureRecognizer::CancelGesture;
break;
}
g = static_cast<QGestureEvent*>(event)->gesture(Qt::SysMgrGestureScreenEdgeFlick);
if (g && g->state() == Qt::GestureFinished && q->state() != Qt::NoGesture ) {
result = QGestureRecognizer::CancelGesture;
break;
}
}
// fall through
#endif // QT_WEBOS
default:
result = QGestureRecognizer::Ignore;
break;
}
return result;
}
示例8: handleSingleTapEvent
void QtWebPageEventHandler::handleSingleTapEvent(const QTouchEvent::TouchPoint& point)
{
m_postponeTextInputStateChanged = true;
QTransform fromItemTransform = m_webPage->transformFromItem();
WebGestureEvent gesture(WebEvent::GestureSingleTap, fromItemTransform.map(point.pos()).toPoint(), point.screenPos().toPoint(), WebEvent::Modifiers(0), 0, IntSize(point.rect().size().toSize()), FloatPoint(0, 0));
m_webPageProxy->handleGestureEvent(gesture);
}
示例9: touchPointCopyPosToLastPos
void MScenePrivate::touchPointCopyPosToLastPos(QTouchEvent::TouchPoint &point)
{
point.setLastPos(point.pos());
point.setLastScenePos(point.scenePos());
point.setLastScreenPos(point.screenPos());
}