当前位置: 首页>>代码示例>>C++>>正文


C++ QTouchEvent::accept方法代码示例

本文整理汇总了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;
}
开发者ID:dumpster-of-things,项目名称:unity8,代码行数:34,代码来源:TouchDispatcher.cpp

示例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();
//.........这里部分代码省略.........
开发者ID:doubletap1410,项目名称:Map,代码行数:101,代码来源:mapuserinteraction.cpp


注:本文中的QTouchEvent::accept方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。