本文整理汇总了C++中QTouchEvent::accept方法的典型用法代码示例。如果您正苦于以下问题:C++ QTouchEvent::accept方法的具体用法?C++ QTouchEvent::accept怎么用?C++ QTouchEvent::accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTouchEvent
的用法示例。
在下文中一共展示了QTouchEvent::accept方法的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: eventFilter
bool MapUserInteraction::eventFilter(QObject *obj, QEvent *event)
{
Q_UNUSED(obj);
Q_D(MapUserInteraction);
Q_ASSERT(d->map);
MapHelper *helper = d->map->helper();
// qDebug() << "Event" << event->type() << helper;
if (!helper)
return false;
switch (event->type()) {
case QEvent::MouseButtonPress: {
QMouseEvent *e = static_cast<QMouseEvent*>(event);
if (helper->mouseDown(e))
e->accept();
break;
}
case QEvent::MouseButtonRelease: {
QMouseEvent *e = static_cast<QMouseEvent*>(event);
if (helper->mouseUp(e))
e->accept();
break;
}
case QEvent::MouseMove: {
QMouseEvent *e = static_cast<QMouseEvent*>(event);
if (helper->mouseMove(e))
e->accept();
break;
}
case QEvent::Wheel: {
QWheelEvent *e = static_cast<QWheelEvent*>(event);
if (helper->wheelEvent(e))
e->accept();
break;
}
case QEvent::KeyPress: {
QKeyEvent *e = static_cast<QKeyEvent*>(event);
if (helper->keyPress(e))
e->accept();
break;
}
case QEvent::KeyRelease: {
QKeyEvent *e = static_cast<QKeyEvent*>(event);
if (helper->keyRelease(e))
e->accept();
break;
}
case QEvent::Gesture: {
#if 0
static bool even = false;
even = !even; // ХЗ почему, но ТАП-ХОЛД срабатывает дважды. Чётные срабатывание откидываем
if (even)
helper->gesture(static_cast<QGestureEvent *>(event));
#endif
break;
#if 0
if (QGesture *swipe = ge->gesture(Qt::SwipeGesture)) {
LogD("GE") << "SwipeGesture";
static_cast<QSwipeGesture *>(swipe);
}
if (QGesture *pan = ge->gesture(Qt::PanGesture)) {
static_cast<QPanGesture *>(pan);
LogD("GE") << "PanGesture";
}
#endif
}
case QEvent::TouchBegin:
{
QTouchEvent *e = static_cast<QTouchEvent *>(event);
if (helper->touch(e))
e->accept();
QList<QTouchEvent::TouchPoint> pts = e->touchPoints();
if (pts.size() == 1) {
QRectF r = pts.first().sceneRect();
r.moveCenter(r.center() - d->map->position());
}
break;
}
case QEvent::TouchEnd:
{
QTouchEvent *e = static_cast<QTouchEvent *>(event);
if (helper->touch(e))
e->accept();
QList<QTouchEvent::TouchPoint> pts = e->touchPoints();
if (pts.size() == 1) {
QRectF r = pts.first().sceneRect();
//.........这里部分代码省略.........