本文整理汇总了C++中QTouchEvent::setDevice方法的典型用法代码示例。如果您正苦于以下问题:C++ QTouchEvent::setDevice方法的具体用法?C++ QTouchEvent::setDevice怎么用?C++ QTouchEvent::setDevice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTouchEvent
的用法示例。
在下文中一共展示了QTouchEvent::setDevice方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
QTouchEvent *TouchDispatcher::createQTouchEvent(QEvent::Type eventType,
QTouchDevice *device,
Qt::KeyboardModifiers modifiers,
const QList<QTouchEvent::TouchPoint> &touchPoints,
QWindow *window,
ulong timestamp)
{
Qt::TouchPointStates eventStates = 0;
for (int i = 0; i < touchPoints.count(); i++)
eventStates |= touchPoints[i].state();
// if all points have the same state, set the event type accordingly
switch (eventStates) {
case Qt::TouchPointPressed:
eventType = QEvent::TouchBegin;
break;
case Qt::TouchPointReleased:
eventType = QEvent::TouchEnd;
break;
default:
eventType = QEvent::TouchUpdate;
break;
}
QTouchEvent *touchEvent = new QTouchEvent(eventType);
touchEvent->setWindow(window);
touchEvent->setTarget(m_targetItem.data());
touchEvent->setDevice(device);
touchEvent->setModifiers(modifiers);
touchEvent->setTouchPoints(touchPoints);
touchEvent->setTouchPointStates(eventStates);
touchEvent->setTimestamp(timestamp);
touchEvent->accept();
return touchEvent;
}
示例2: handlePointerEvent
void RenderableWebEntityItem::handlePointerEvent(const PointerEvent& event) {
// Ignore mouse interaction if we're locked
if (getLocked() || !_webSurface) {
return;
}
glm::vec2 windowPos = event.getPos2D() * (METERS_TO_INCHES * _dpi);
QPointF windowPoint(windowPos.x, windowPos.y);
if (event.getType() == PointerEvent::Move) {
// Forward a mouse move event to webSurface
QMouseEvent* mouseEvent = new QMouseEvent(QEvent::MouseMove, windowPoint, windowPoint, windowPoint, Qt::NoButton, Qt::NoButton, Qt::NoModifier);
QCoreApplication::postEvent(_webSurface->getWindow(), mouseEvent);
}
{
// Forward a touch update event to webSurface
if (event.getType() == PointerEvent::Press) {
this->_pressed = true;
} else if (event.getType() == PointerEvent::Release) {
this->_pressed = false;
}
QEvent::Type type;
Qt::TouchPointState touchPointState;
switch (event.getType()) {
case PointerEvent::Press:
type = QEvent::TouchBegin;
touchPointState = Qt::TouchPointPressed;
break;
case PointerEvent::Release:
type = QEvent::TouchEnd;
touchPointState = Qt::TouchPointReleased;
break;
case PointerEvent::Move:
default:
type = QEvent::TouchUpdate;
touchPointState = Qt::TouchPointMoved;
break;
}
QTouchEvent::TouchPoint point;
point.setId(event.getID());
point.setState(touchPointState);
point.setPos(windowPoint);
point.setScreenPos(windowPoint);
QList<QTouchEvent::TouchPoint> touchPoints;
touchPoints.push_back(point);
QTouchEvent* touchEvent = new QTouchEvent(type);
touchEvent->setWindow(nullptr);
touchEvent->setDevice(nullptr);
touchEvent->setTarget(nullptr);
touchEvent->setTouchPoints(touchPoints);
touchEvent->setTouchPointStates(touchPointState);
_lastTouchEvent = *touchEvent;
QCoreApplication::postEvent(_webSurface->getWindow(), touchEvent);
}
}