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


C++ QPanGesture::acceleration方法代码示例

本文整理汇总了C++中QPanGesture::acceleration方法的典型用法代码示例。如果您正苦于以下问题:C++ QPanGesture::acceleration方法的具体用法?C++ QPanGesture::acceleration怎么用?C++ QPanGesture::acceleration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QPanGesture的用法示例。


在下文中一共展示了QPanGesture::acceleration方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: event

bool ModelSelectionPane::event(QEvent *event)
{
#if 0
    if(event->type() == QEvent::Gesture) {
        LogManagerInst << LogManager::LogDegreeType_Normal << "QEvent::Gesture";
        QGestureEvent* gestureEvent = static_cast<QGestureEvent*>(event);
        QGesture *gesture = gestureEvent->gesture(Qt::PanGesture);
        if(NULL == gestureEvent) {
            LogManagerInst << LogManager::LogDegreeType_Error << "QEvent::Gesture is NULL";
        }else {
            QList<QGesture *> gestures = gestureEvent->gestures();
            QList<QGesture *> activeGestures = gestureEvent->activeGestures();

            LogManagerInst << "Gesture Value" << QString::number((int)gesture, 16);

            LogManagerInst << LogManager::LogDegreeType_Normal << "Gesture Count" << QString::number(gestures.count()) << "activeGestures Count" << QString::number(activeGestures.count());
            LogManagerInst << LogManager::LogDegreeType_Normal
                << (gestureEvent->gesture(Qt::TapGesture) != NULL?"TapGesture":"")
                << (gestureEvent->gesture(Qt::TapAndHoldGesture) != NULL?"TapAndHoldGesture":"")
                << ((NULL != gesture)?"PanGesture":"")
                << (gestureEvent->gesture(Qt::PinchGesture) != NULL?"PinchGesture":"")
                << (gestureEvent->gesture(Qt::SwipeGesture) != NULL?"SwipeGesture":"") ;
        }

        LogManagerInst << (gesture == NULL?"PanGesture == NULL":"PanGesture != NULL");
        if(gesture != NULL) {
            LogManagerInst << LogManager::LogDegreeType_Normal << "Handle Pan Gesture";
            QPanGesture* panGesture = static_cast<QPanGesture*>(gesture);
            LogManagerInst << LogManager::LogDegreeType_Normal << "Acceleration" << QString::number(panGesture->acceleration());
            LogManagerInst << LogManager::LogDegreeType_Normal << "delta" << QString::number(panGesture->delta().x());
            LogManagerInst << LogManager::LogDegreeType_Normal << "State" << QString::number(gesture->state());
            if(gesture->state() == Qt::GestureFinished) {
                if((panGesture->acceleration() > 2) || (panGesture->delta().x() > width()/2)) {
                    FlipAnimationStart(panGesture->delta().x() > 0 ? FlipDirection_Right : FlipDirection_Left);
                }
            } else {
                LogManagerInst << LogManager::LogDegreeType_Normal << "Position" << QString::number(ui->itemsetpane->x());
                QPoint targetPos = ui->itemsetpane->pos()+QPoint(panGesture->delta().x(),0);
                if(targetPos.x() > width()/4) {
                    targetPos.setX(width()/4);
                } else if(targetPos.x() < width() - m_itemSetPaneSize.width() - width()/4) {
                    targetPos.setX(width() - m_itemSetPaneSize.width() - width()/4);
                } else {

                }
                ui->itemsetpane->move(targetPos);
            }
        }
    }
#endif

#if 1
    /*****
     * 外面是阴天,我也成了阴天
     * 狗屎的Gesture
     * Document明明图示QPanGesture是一个手指
     * 源码里却他妈的是3个
     * 你他妈的逗我么
     * 我就是个秀逗
     * 明天dota只能用秀逗了
     * 悲剧啊悲剧啊
     * 我的时间
     * 如同我的身体老去
     *****/

    bool flipAction = false;
    static float last_x = 0.0f;
    static float touchBeginLastX = 0.0f;

    int deltaX = 0;
    float acceleration = 0.0f;

    switch(event->type()) {
#if 1
    case QEvent::TouchBegin: {
        LogManagerInst << LogManager::LogDegreeType_Normal  << "TouchBegin";
        flipAction = true;
        m_time.start();
        const QTouchEvent *touchEvent = static_cast<const QTouchEvent *>(event);
        QTouchEvent::TouchPoint touchPoint = touchEvent->touchPoints().first();
        last_x = touchPoint.pos().x();
        touchBeginLastX = touchPoint.pos().x();
    }
        break;
    case QEvent::TouchUpdate: {
        LogManagerInst << LogManager::LogDegreeType_Normal  << "TouchUpdate";
        flipAction = true;
        const QTouchEvent *touchEvent = static_cast<const QTouchEvent *>(event);
        QTouchEvent::TouchPoint touchPoint = touchEvent->touchPoints().first();
        deltaX = touchPoint.pos().x() - last_x;
        last_x = touchPoint.pos().x();
    }
        break;

    case QEvent::TouchEnd: {
        LogManagerInst << LogManager::LogDegreeType_Normal  << "TouchEnd";
        flipAction = true;
        const QTouchEvent *touchEvent = static_cast<const QTouchEvent *>(event);
        QTouchEvent::TouchPoint touchPoint = touchEvent->touchPoints().first();
        int elapseTime = m_time.elapsed();
//.........这里部分代码省略.........
开发者ID:dayuanyuan1989,项目名称:RemoteBinder,代码行数:101,代码来源:modelselectionpane.cpp


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