本文整理汇总了C++中qtouchevent::TouchPoint::pos方法的典型用法代码示例。如果您正苦于以下问题:C++ TouchPoint::pos方法的具体用法?C++ TouchPoint::pos怎么用?C++ TouchPoint::pos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtouchevent::TouchPoint
的用法示例。
在下文中一共展示了TouchPoint::pos方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateTouchPoint
void GestureEngine::updateTouchPoint(QTouchEvent::TouchPoint e)
{
gwc::touchpoint updated_point;
updated_point.init(e.id(), e.pos().x() / 1920, e.pos().y()/ 1080, 0, 1, 1);
updated_point.status = gwc::TOUCHUPDATE;
addEvent(updated_point);
}
示例2: removeTouchPoint
void GestureEngine::removeTouchPoint(QTouchEvent::TouchPoint e)
{
gwc::touchpoint removed_point;
removed_point.init(e.id(), e.pos().x() / 1920, e.pos().y()/ 1080, 0, 1, 1);
removed_point.status = gwc::TOUCHREMOVED;
addEvent(removed_point);
}
示例3: addTouchPoint
void GestureEngine::addTouchPoint(QTouchEvent::TouchPoint e)
{
gwc::touchpoint new_point;
new_point.init(e.id(), e.pos().x() / 1920, e.pos().y() / 1080, 0, 1920, 1080);
new_point.status = gwc::TOUCHADDED;
addEvent(new_point);
qDebug() << "Added to Gestureworks";
}
示例4: event
bool TreeViewTouch::event(QEvent *event) {
#if QT_VERSION >= 0x050000
if (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->device()->type()==QTouchDevice::TouchScreen) {
#else
if (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->deviceType()==QTouchEvent::TouchScreen) {
#endif
// Register that we may be scrolling, set the scroll mode to scroll-per-pixel
// and accept the event (return true) so that we will receive TouchUpdate and TouchEnd/TouchCancel
_touchScrollInProgress = true;
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
return true;
}
if (event->type() == QEvent::TouchUpdate && _touchScrollInProgress) {
QTouchEvent::TouchPoint p = ((QTouchEvent*)event)->touchPoints().at(0);
if (!_firstTouchUpdateHappened) {
// After the first movement of a Touch-Point, calculate the distance in both axis
// and if the point moved more horizontally abort scroll.
double dx = qAbs(p.lastPos().x() - p.pos().x());
double dy = qAbs(p.lastPos().y() - p.pos().y());
if (dx > dy) {
_touchScrollInProgress = false;
}
_firstTouchUpdateHappened = true;
}
// Apply touch movement to scrollbar
verticalScrollBar()->setValue(verticalScrollBar()->value() - (p.pos().y() - p.lastPos().y()));
return true;
}
#if QT_VERSION >= 0x050000
if (event->type() == QEvent::TouchEnd || event->type() == QEvent::TouchCancel) {
#else
if (event->type() == QEvent::TouchEnd) {
#endif
// End scroll and reset variables
_touchScrollInProgress = false;
_firstTouchUpdateHappened = false;
return true;
}
return QTreeView::event(event);
}
void TreeViewTouch::mousePressEvent(QMouseEvent *event) {
if (!_touchScrollInProgress)
QTreeView::mousePressEvent(event);
}
void TreeViewTouch::mouseMoveEvent(QMouseEvent *event) {
if (!_touchScrollInProgress)
QTreeView::mouseMoveEvent(event);
};
示例5: activateTapHighlight
void QtWebPageEventHandler::activateTapHighlight(const QTouchEvent::TouchPoint& point)
{
#if ENABLE(TOUCH_EVENTS)
ASSERT(!point.pos().toPoint().isNull());
ASSERT(!m_isTapHighlightActive);
m_isTapHighlightActive = true;
QTransform fromItemTransform = m_webPage->transformFromItem();
m_webPageProxy->handlePotentialActivation(IntPoint(fromItemTransform.map(point.pos()).toPoint()), IntSize(point.rect().size().toSize()));
#else
Q_UNUSED(point);
#endif
}
示例6: handlePotentialSingleTapEvent
void QtWebPageEventHandler::handlePotentialSingleTapEvent(const QTouchEvent::TouchPoint& point)
{
#if ENABLE(TOUCH_EVENTS)
if (point.pos() == QPointF()) {
// An empty point deactivates the highlighting.
m_webPageProxy->handlePotentialActivation(IntPoint(), IntSize());
} else {
QTransform fromItemTransform = m_webPage->transformFromItem();
m_webPageProxy->handlePotentialActivation(IntPoint(fromItemTransform.map(point.pos()).toPoint()), IntSize(point.rect().size().toSize()));
}
#else
Q_UNUSED(point);
#endif
}
示例7: 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);
}
示例8: handleDoubleTapEvent
void QtWebPageEventHandler::handleDoubleTapEvent(const QTouchEvent::TouchPoint& point)
{
if (!m_webView->isInteractive())
return;
deactivateTapHighlight();
QTransform fromItemTransform = m_webPage->transformFromItem();
m_webPageProxy->findZoomableAreaForPoint(fromItemTransform.map(point.pos()).toPoint(), IntSize(point.rect().size().toSize()));
}
示例9: processTouchEvent
void MainGraphicsView::processTouchEvent(QTouchEvent *touchEvent) {
QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();
//qDebug("touch event %d count %d", event->type(), touchPoints.count());
if( touchPoints.count() > 1 ) {
this->has_kinetic_scroll = false;
this->single_left_mouse_down = false;
// can't trust last mouse position if more that one touch!
this->has_last_mouse = false;
}
#if QT_VERSION >= 0x050000
#ifdef Q_OS_ANDROID
// on Android with Qt 5, mouse events are never received, instead it's done purely via touch events
if( touchPoints.count() == 1 ) {
QTouchEvent::TouchPoint touchPoint = touchPoints.at(0);
int m_x = touchPoint.pos().x();
int m_y = touchPoint.pos().y();
if( touchEvent->type() == QEvent::TouchBegin ) {
this->mousePress(m_x, m_y);
}
else if( touchEvent->type() == QEvent::TouchEnd ) {
this->mouseRelease(m_x, m_y);
}
else if( touchEvent->type() == QEvent::TouchUpdate ) {
this->mouseMove(m_x, m_y);
}
}
#endif
#endif
if( touchPoints.count() == 2 ) {
// determine scale factor
const QTouchEvent::TouchPoint &touchPoint0 = touchPoints.first();
const QTouchEvent::TouchPoint &touchPoint1 = touchPoints.last();
/*float scale_factor =
QLineF(touchPoint0.pos(), touchPoint1.pos()).length()
/ QLineF(touchPoint0.startPos(), touchPoint1.startPos()).length();*/
QPointF touch_centre = (touchPoint0.pos() + touchPoint1.pos())*0.5;
QPointF zoom_centre = this->mapToScene(QPoint(touch_centre.x(), touch_centre.y()));
float scale_factor =
QLineF(touchPoint0.pos(), touchPoint1.pos()).length()
/ QLineF(touchPoint0.lastPos(), touchPoint1.lastPos()).length();
/*if (touchEvent->touchPointStates() & Qt::TouchPointReleased) {
// if one of the fingers is released, remember the current scale
// factor so that adding another finger later will continue zooming
// by adding new scale factor to the existing remembered value.
totalScaleFactor *= currentScaleFactor;
currentScaleFactor = 1;
}*/
/*setTransform(QTransform().scale(totalScaleFactor * currentScaleFactor,
totalScaleFactor * currentScaleFactor));*/
float n_scale = c_scale *scale_factor;
//LOG("multitouch scale: %f : %f\n", scale_factor, n_scale);
this->setScale(zoom_centre, n_scale);
}
}
示例10: switch
QGestureRecognizer::Result
QTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object,
QEvent *event)
{
QTapAndHoldGesture *q = static_cast<QTapAndHoldGesture *>(state);
QTapAndHoldGesturePrivate *d = q->d_func();
if (object == state && event->type() == QEvent::Timer) {
q->killTimer(d->timerId);
d->timerId = 0;
return QGestureRecognizer::Ignore | QGestureRecognizer::ConsumeEventHint;
}
const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
QGestureRecognizer::Result result = QGestureRecognizer::CancelGesture;
enum { TimerInterval = 2000 };
enum { TapRadius = 40 };
switch (event->type()) {
case QEvent::TouchBegin:
d->position = ev->touchPoints().at(0).pos();
if (d->timerId)
q->killTimer(d->timerId);
d->timerId = q->startTimer(TimerInterval);
result = QGestureRecognizer::TriggerGesture;
break;
case QEvent::TouchEnd:
if (d->timerId)
result = QGestureRecognizer::CancelGesture;
else
result = QGestureRecognizer::FinishGesture;
break;
case QEvent::TouchUpdate:
if (q->state() != Qt::NoGesture && ev->touchPoints().size() == 1) {
QTouchEvent::TouchPoint p = ev->touchPoints().at(0);
QPoint delta = p.pos().toPoint() - p.startPos().toPoint();
if (delta.manhattanLength() <= TapRadius)
result = QGestureRecognizer::TriggerGesture;
}
break;
case QEvent::MouseButtonPress:
case QEvent::MouseMove:
case QEvent::MouseButtonRelease:
result = QGestureRecognizer::Ignore;
break;
default:
result = QGestureRecognizer::Ignore;
break;
}
return result;
}
示例11: switch
QGestureRecognizer::Result
WebosTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object,
QEvent *event)
{
QGestureRecognizer::Result result = QGestureRecognizer::CancelGesture;
WebosTapAndHoldGesture *q = static_cast<WebosTapAndHoldGesture *>(state);
if (object == state && event->type() == QEvent::Timer) {
q->stopTapTimer();
if (q->state() != Qt::NoGesture && q->state() != Qt::GestureCanceled) {
result = QGestureRecognizer::FinishGesture;
}
return result | QGestureRecognizer::ConsumeEventHint;
}
const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
//Todo Here use a const value to set up the timer interval but maybe need to use the Timeout value
//enum { TimerInterval = 700 };
enum { TapRadius = 40 };
switch (event->type()) {
case QEvent::TouchBegin:
q->setPosition(ev->touchPoints().at(0).startScreenPos());
q->setHotSpot(q->position());
q->stopTapTimer();
q->startTapTimer();
return QGestureRecognizer::TriggerGesture;
case QEvent::TouchEnd:
result = QGestureRecognizer::CancelGesture;
q->stopTapTimer();
break;
case QEvent::TouchUpdate:
if (q->tapTimerId() && ev->touchPoints().size() == 1) {
QTouchEvent::TouchPoint p = ev->touchPoints().at(0);
QPoint delta = p.pos().toPoint() - p.startPos().toPoint();
if (delta.manhattanLength() > TapRadius) {
result = QGestureRecognizer::CancelGesture;
q->stopTapTimer();
} else {
result = QGestureRecognizer::Ignore;
}
} else if (ev->touchPoints().size() > 1) {
result = QGestureRecognizer::CancelGesture;
q->stopTapTimer();
} else {
result = QGestureRecognizer::Ignore;
}
break;
default:
return QGestureRecognizer::Ignore;
}
return result;
}
示例12: 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);
}
示例13: touchStateToString
QDebug operator<<(QDebug dbg, const QTouchEvent::TouchPoint &s)
{
dbg.nospace() << "\"TouchPoint\":"
<< "{ \"id\":" << s.id()
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
<< ", \"primary\":\"" << (s.isPrimary() ? "true" : "false") << "\""
#endif
<< ", \"state\":" << touchStateToString(s.state())
<< ", \"pos\":\"" << s.pos() << "\""
<< ", \"pressure\":\"" << s.pressure() << "\""
<< " }";
return dbg.space();
}
示例14: 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();
}
示例15: 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: {
d->position = ev->touchPoints().at(0).pos();
q->setHotSpot(ev->touchPoints().at(0).screenPos());
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);
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;
default:
result = QGestureRecognizer::Ignore;
break;
}
return result;
}