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


C++ QTouchEvent类代码示例

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


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

示例1: switch

bool QGraphicsMozView::event(QEvent* event)
{
    switch (event->type()) {
    case QEvent::TouchBegin:
    case QEvent::TouchUpdate:
    case QEvent::TouchEnd: {
        QTouchEvent* touch = static_cast<QTouchEvent*>(event);
        if (!mUseQmlMouse || touch->touchPoints().size() > 1) {
            d->touchEvent(touch);
        }
        return true;
    }
    case QEvent::Show: {
        LOGT("Event Show: curCtx:%p", (void*)QGLContext::currentContext());
        break;
    }
    case QEvent::Hide: {
        LOGT("Event Hide");
        break;
    }
    default:
        break;
    }

    // Here so that it can be reimplemented without breaking ABI.
    return QGraphicsWidget::event(event);
}
开发者ID:android-808,项目名称:microbe,代码行数:27,代码来源:qgraphicsmozview.cpp

示例2: HsWidgetHost

void TestHsDomainModel::testWidgetTouchAreaSceneEvent()
{
    HsWidgetHost *widget = new HsWidgetHost(-1);
    HsWidgetTouchArea *widgetTouchArea = new HsWidgetTouchArea(widget->visual());
    HsScene *scene = HsScene::instance();

    // test shape fetch
    QPainterPath *path = new QPainterPath(widgetTouchArea->shape());
    QVERIFY(path);
    delete path;

    QSignalSpy widgetTapStartedSpy(scene, SIGNAL(widgetTapStarted(QPointF,HsWidgetHost*)));
    QSignalSpy widgetMoveFinishedSpy(scene, SIGNAL(widgetMoveFinished(const QPointF &, HsWidgetHost*)));

    // test touch begin
    QTouchEvent::TouchPoint touchPoint;
    QList<QTouchEvent::TouchPoint> touchPoints;
    touchPoints.append(touchPoint);
    QTouchEvent *touchEvent = new QTouchEvent(QEvent::TouchBegin);
    touchEvent->setTouchPoints(touchPoints);
    widgetTouchArea->sceneEvent(touchEvent);
    QCOMPARE(widgetTapStartedSpy.count(), 1);

    delete widgetTouchArea;    
    delete widget;  
}
开发者ID:cdaffara,项目名称:symbiandump-ossapps,代码行数:26,代码来源:t_hswidgettoucharea.cpp

示例3: Q_D

bool QDeclarativePinchArea::event(QEvent *event)
{
    Q_D(QDeclarativePinchArea);
    if (!d->absorb || !isVisible())
        return QDeclarativeItem::event(event);
    switch (event->type()) {
    case QEvent::TouchBegin:
        d->touchEventsActive = true;
        // No break, continue to next case.
    case QEvent::TouchUpdate:
        if (d->touchEventsActive) {
            QTouchEvent *touch = static_cast<QTouchEvent*>(event);
            d->touchPoints.clear();
            for (int i = 0; i < touch->touchPoints().count(); ++i) {
                if (!(touch->touchPoints().at(i).state() & Qt::TouchPointReleased)) {
                    d->touchPoints << touch->touchPoints().at(i);
                }
            }
            updatePinch();
            return true;
        }
        break;
    case QEvent::WindowDeactivate:
        // No break, continue to next case.
    case QEvent::TouchEnd:
        d->touchEventsActive = false;
        d->touchPoints.clear();
        updatePinch();
        break;
    default:
        return QDeclarativeItem::event(event);
    }

    return QDeclarativeItem::event(event);
}
开发者ID:AtlantisCD9,项目名称:Qt,代码行数:35,代码来源:qdeclarativepincharea.cpp

示例4: Q_D

bool QQuickPinchArea::childMouseEventFilter(QQuickItem *i, QEvent *e)
{
    Q_D(QQuickPinchArea);
    if (!d->enabled || !isVisible())
        return QQuickItem::childMouseEventFilter(i, e);
    switch (e->type()) {
    case QEvent::TouchBegin:
    case QEvent::TouchUpdate: {
            QTouchEvent *touch = static_cast<QTouchEvent*>(e);
            if (touch->touchPoints().count() > 1) {
                touchEvent(touch);
            } else {
                d->touchPoints.clear();
                for (int i = 0; i < touch->touchPoints().count(); ++i)
                    if (!(touch->touchPoints().at(i).state() & Qt::TouchPointReleased))
                        d->touchPoints << touch->touchPoints().at(i);
                updatePinch();
            }
        }
        return d->inPinch;
    case QEvent::TouchEnd:
        d->touchPoints.clear();
        updatePinch();
        break;
    default:
        break;
    }

    return QQuickItem::childMouseEventFilter(i, e);
}
开发者ID:SamuelNevala,项目名称:qtdeclarative,代码行数:30,代码来源:qquickpincharea.cpp

示例5: switch

bool Knob::sceneEvent(QEvent *event)
{
    switch (event->type()) {
    case QEvent::TouchBegin:
    case QEvent::TouchUpdate:
    case QEvent::TouchEnd:
    {
        QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);

        if (touchEvent->touchPoints().count() == 2) {
            const QTouchEvent::TouchPoint &touchPoint1 = touchEvent->touchPoints().first();
            const QTouchEvent::TouchPoint &touchPoint2 = touchEvent->touchPoints().last();

            QLineF line1(touchPoint1.lastScenePos(), touchPoint2.lastScenePos());
            QLineF line2(touchPoint1.scenePos(), touchPoint2.scenePos());

            rotate(line2.angleTo(line1));
        }

        break;
    }

    default:
        return QGraphicsItem::sceneEvent(event);
    }

    return true;
}
开发者ID:Kwangsub,项目名称:qt-openwebos,代码行数:28,代码来源:knob.cpp

示例6: switch

bool StelSkyItem::event(QEvent * e)
{
	switch (e->type()){
	case QEvent::TouchBegin:
	case QEvent::TouchUpdate:
	case QEvent::TouchEnd:
	{
		QTouchEvent *touchEvent = static_cast<QTouchEvent *>(e);
		QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();

		if (touchPoints.count() == 1)
			setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton | Qt::MiddleButton);

		return true;
		break;
	}

	case QEvent::Gesture:
		setAcceptedMouseButtons(0);
		return gestureEvent(static_cast<QGestureEvent*>(e));
		break;

	default:
		return QGraphicsWidget::event(e);
	}
}
开发者ID:magnific0,项目名称:stellarium,代码行数:26,代码来源:StelMainView.cpp

示例7: switch

bool GraphicsView::viewportEvent(QEvent *event)
{
    switch (event->type()) {
    case QEvent::TouchBegin:
    case QEvent::TouchUpdate:
    case QEvent::TouchEnd:
    {
        QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);
        QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();
        if (touchPoints.count() == 2) {
            // determine scale factor
            const QTouchEvent::TouchPoint &touchPoint0 = touchPoints.first();
            const QTouchEvent::TouchPoint &touchPoint1 = touchPoints.last();
            qreal currentScaleFactor =
                    QLineF(touchPoint0.pos(), touchPoint1.pos()).length()
                    / QLineF(touchPoint0.startPos(), touchPoint1.startPos()).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));
        }
        return true;
    }
    default:
        break;
    }
    return QGraphicsView::viewportEvent(event);
}
开发者ID:Andreas665,项目名称:qt,代码行数:33,代码来源:graphicsview.cpp

示例8: switch

bool Knob::sceneEvent(QEvent *event)
{
    switch (event->type()) {
    case QEvent::TouchBegin:{
        qDebug("start!!! ") ;
       // emit startTouch();
        break;
    }
    case QEvent::TouchUpdate:{
        qDebug("UPDATE!!! ") ;
        QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);
         const QTouchEvent::TouchPoint &touchPoint1 = touchEvent->touchPoints().first();
         qDebug()<< touchPoint1.scenePos().x()<< "   +  " <<touchPoint1.scenePos().y();
         leftItem->setPos(touchPoint1.scenePos().x()-140,touchPoint1.scenePos().y()-140 );
       //  emit sendPos(touchPoint1.scenePos().x()-140,touchPoint1.scenePos().y()-140);
        break;
    }
    case QEvent::TouchEnd:
    {
       //  emit stopTouch();

        break;
    }

    default:
        return QGraphicsItem::sceneEvent(event);
    }

    return true;
}
开发者ID:cyniu88,项目名称:QT_kurs,代码行数:30,代码来源:knob.cpp

示例9: Q_D

bool QDeclarativePinchArea::event(QEvent *event)
{
    Q_D(QDeclarativePinchArea);
    if (!d->absorb || !isVisible())
        return QDeclarativeItem::event(event);
    switch (event->type()) {
    case QEvent::TouchBegin:
    case QEvent::TouchUpdate: {
            QTouchEvent *touch = static_cast<QTouchEvent*>(event);
            d->touchPoints.clear();
            for (int i = 0; i < touch->touchPoints().count(); ++i) {
                if (!(touch->touchPoints().at(i).state() & Qt::TouchPointReleased)) {
                    d->touchPoints << touch->touchPoints().at(i);
                }
            }
            updatePinch();
        }
        return true;
    case QEvent::TouchEnd:
        d->touchPoints.clear();
        updatePinch();
        break;
    default:
        return QDeclarativeItem::event(event);
    }

    return QDeclarativeItem::event(event);
}
开发者ID:BGmot,项目名称:Qt,代码行数:28,代码来源:qdeclarativepincharea.cpp

示例10: sceneEvent

bool PuzzleBoardItem::sceneEvent(QEvent *event)
{
    if (event->type() == QEvent::TouchBegin || event->type() == QEvent::TouchUpdate || event->type() == QEvent::TouchEnd)
    {
        QTouchEvent *te = static_cast<QTouchEvent*>(event);

        if (te->touchPoints().count() == 1)
        {
            QTouchEvent::TouchPoint tp = te->touchPoints().first();
            QPointF diff = tp.screenPos() - this->game()->rotationGuideCoordinates();
            if (abs(diff.x()) < 32 && abs(diff.y()) < 32)
            {
                event->ignore();
                return false;
            }
        }

        event->accept();
        _game->handleTouchEvent(te);
        if (!_autoRepainter->isActive())
            update();
        return true;
    }

    return QDeclarativeItem::sceneEvent(event);
}
开发者ID:Jornason,项目名称:puzzle-master,代码行数:26,代码来源:puzzleboarditem_qt4.cpp

示例11: switch

bool ReticleHandler::eventFilter(QObject *, QEvent *event)
{
	static bool show = true;
	switch (event->type()) {
	case QEvent::TouchBegin:
		show = true;
		break;
	case QEvent::TouchUpdate:
		show = false;
		break;
	case QEvent::TouchCancel:
		show = false;
		break;
	case QEvent::TouchEnd:
		{
			if (show) {
				QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);
				const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().first();
				QPointF fpoint = touchPoint.pos();
				int x = static_cast<int>(fpoint.x());
				int y = static_cast<int>(fpoint.y());

				QScreen *primaryScreen = QGuiApplication::primaryScreen();
				QTransform lOrientationTranform = primaryScreen->transformBetween(primaryScreen->orientation(), primaryScreen->primaryOrientation(), primaryScreen->geometry()).inverted();

				emit reticleEvent(lOrientationTranform.map(QPoint(x,y)));
			};
			show = false;
		}
		break;
	}
	return false;
}
开发者ID:Andolamin,项目名称:luna-next,代码行数:33,代码来源:reticlehandler.cpp

示例12: switch

bool ReticleHandler::eventFilter(QObject *, QEvent *event)
{
	static bool show = true;
	switch (event->type()) {
	case QEvent::TouchBegin:
		show = true;
		break;
	case QEvent::TouchUpdate:
		show = false;
		break;
	case QEvent::TouchCancel:
		show = false;
		break;
	case QEvent::TouchEnd:
		{
			if (show) {
				QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);
				const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().first();
				QPointF fpoint = touchPoint.pos();
				int x = static_cast<int>(fpoint.x());
				int y = static_cast<int>(fpoint.y());
				QPoint point(x,y);
				emit reticleEvent(point);
			};
			show = false;
		}
		break;
	}
	return false;
}
开发者ID:thrrgilag,项目名称:luna-next,代码行数:30,代码来源:reticlehandler.cpp

示例13: viewportEvent

bool ScrollArea::viewportEvent(QEvent *e) {
	if (e->type() == QEvent::TouchBegin || e->type() == QEvent::TouchUpdate || e->type() == QEvent::TouchEnd || e->type() == QEvent::TouchCancel) {
		QTouchEvent *ev = static_cast<QTouchEvent*>(e);
		if (_touchEnabled && ev->device()->type() == QTouchDevice::TouchScreen) {
			touchEvent(ev);
			return true;
		}
	}
	return QScrollArea::viewportEvent(e);
}
开发者ID:2asoft,项目名称:tdesktop,代码行数:10,代码来源:scrollarea.cpp

示例14: event

bool FlatLabel::event(QEvent *e) {
	if (e->type() == QEvent::TouchBegin || e->type() == QEvent::TouchUpdate || e->type() == QEvent::TouchEnd || e->type() == QEvent::TouchCancel) {
		QTouchEvent *ev = static_cast<QTouchEvent*>(e);
		if (ev->device()->type() == QTouchDevice::TouchScreen) {
			touchEvent(ev);
			return true;
		}
	}
	return QWidget::event(e);
}
开发者ID:banditkroot,项目名称:tdesktop,代码行数:10,代码来源:flatlabel.cpp

示例15: viewportEvent

bool InputField::InputFieldInner::viewportEvent(QEvent *e) {
	if (e->type() == QEvent::TouchBegin || e->type() == QEvent::TouchUpdate || e->type() == QEvent::TouchEnd || e->type() == QEvent::TouchCancel) {
		QTouchEvent *ev = static_cast<QTouchEvent*>(e);
		if (ev->device()->type() == QTouchDevice::TouchScreen) {
			qobject_cast<InputField*>(parentWidget())->touchEvent(ev);
			return QTextEdit::viewportEvent(e);
		}
	}
	return QTextEdit::viewportEvent(e);
}
开发者ID:noscripter,项目名称:tdesktop,代码行数:10,代码来源:flatinput.cpp


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