本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}