本文整理汇总了C++中QTouchEvent::touchPoints方法的典型用法代码示例。如果您正苦于以下问题:C++ QTouchEvent::touchPoints方法的具体用法?C++ QTouchEvent::touchPoints怎么用?C++ QTouchEvent::touchPoints使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTouchEvent
的用法示例。
在下文中一共展示了QTouchEvent::touchPoints方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: childMouseEventFilter
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);
}
示例2: event
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);
}
示例3: event
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);
}
示例4: 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);
}
示例5: sceneEvent
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: sceneEventFilter
bool QDeclarativePinchArea::sceneEventFilter(QGraphicsItem *i, QEvent *e)
{
Q_D(QDeclarativePinchArea);
if (!d->absorb || !isVisible())
return QDeclarativeItem::sceneEventFilter(i, e);
switch (e->type()) {
case QEvent::GraphicsSceneMousePress:
case QEvent::GraphicsSceneMouseMove:
case QEvent::GraphicsSceneMouseRelease:
return sendMouseEvent(static_cast<QGraphicsSceneMouseEvent *>(e));
break;
case QEvent::TouchBegin:
case QEvent::TouchUpdate: {
QTouchEvent *touch = static_cast<QTouchEvent*>(e);
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 QDeclarativeItem::sceneEventFilter(i, e);
}
示例7: event
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);
}
}
示例8: sceneEvent
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: eventFilter
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;
}
示例10: eventFilter
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;
}
示例11: event
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);
}
示例12: viewportEvent
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);
}
示例13: recognize
QGestureRecognizer::Result ThreeFingerSlideGestureRecognizer::recognize(QGesture *state, QObject *, QEvent *event)
{
ThreeFingerSlideGesture *d = static_cast<ThreeFingerSlideGesture *>(state);
QGestureRecognizer::Result result;
switch (event->type()) {
case QEvent::TouchBegin:
result = QGestureRecognizer::MayBeGesture;
case QEvent::TouchEnd:
if (d->gestureFired)
result = QGestureRecognizer::FinishGesture;
else
result = QGestureRecognizer::CancelGesture;
case QEvent::TouchUpdate:
if (d->state() != Qt::NoGesture) {
QTouchEvent *ev = static_cast<QTouchEvent*>(event);
if (ev->touchPoints().size() == 3) {
d->gestureFired = true;
result = QGestureRecognizer::TriggerGesture;
} else {
result = QGestureRecognizer::MayBeGesture;
for (int i = 0; i < ev->touchPoints().size(); ++i) {
const QTouchEvent::TouchPoint &pt = ev->touchPoints().at(i);
const int distance = (pt.pos().toPoint() - pt.startPos().toPoint()).manhattanLength();
if (distance > 20) {
result = QGestureRecognizer::CancelGesture;
}
}
}
} else {
result = QGestureRecognizer::CancelGesture;
}
break;
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
case QEvent::MouseMove:
if (d->state() != Qt::NoGesture)
result = QGestureRecognizer::Ignore;
else
result = QGestureRecognizer::CancelGesture;
break;
default:
result = QGestureRecognizer::Ignore;
break;
}
return result;
}
示例14: viewportEvent
bool controlGraph::viewportEvent(QEvent *event)
{
QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);
switch (event->type()) {
case QEvent::TouchBegin: {
qDebug() << "touch TouchBegin";
return true;
}
case QEvent::TouchUpdate: {
if(touchEvent->touchPoints().size() < 2) {
// emit touchMove(0, 0);
return(true);
}
qDebug() << "touch TouchUpdate";
const QTouchEvent::TouchPoint &touchPoint0 = touchEvent->touchPoints().first();
int s = 1;
if(touchEvent->touchPoints().size() == 3)s = 10;
float deltaX = touchPoint0.normalizedPos().x() - touchPoint0.startNormalizedPos().x();
float deltaY = touchPoint0.normalizedPos().y() - touchPoint0.startNormalizedPos().y();
// if(deltaX > -0.01 && deltaX < 0.01)deltaX=0;
// if(deltaY > -0.01 && deltaY < 0.01)deltaY=0;
emit touchMove(deltaX/s, deltaY/s);
return true;
}
case QEvent::TouchEnd:
{
emit touchMove(0, 0);
return true;
}
case QEvent::TouchCancel:
{
emit touchMove(0, 0);
return true;
}
default:
break;
}
return QGraphicsView::viewportEvent(event);
}
示例15: viewportEvent
/**
* Touch events are processed here and @p TscoreItem gets only @p touched() @p touchMove() and @p untouched()
* with latest touch position in scene coordinates. To use them, TscoreItem subclass has to map it first.
* When second finger touches screen, last touch event is canceled by putting null point as a parameter.
* So far, only: @class TscoreNote, @class TscoreKeySignature and @class TscoreClef handles those methods.
* Two fingers touch is used to scroll score
*/
bool TsimpleScore::viewportEvent(QEvent* event) {
if (TscoreNote::touchEnabled()) {
if (event->type() == QEvent::TouchBegin || event->type() == QEvent::TouchUpdate || event->type() == QEvent::TouchEnd) {
QTouchEvent *te = static_cast<QTouchEvent*>(event);
if (te->touchPoints().count() == 1) {
// Touch event is sent here with view coordinates points - their has to be mapped to score scene
QPointF touchScenePos = mapToScene(te->touchPoints().first().pos().toPoint());
switch(te->touchPoints().first().state()) {
case Qt::TouchPointPressed: {
TscoreItem *it = castItem(scene()->itemAt(touchScenePos, transform()));
if (it) {
it->touched(touchScenePos);
m_currentIt = it;
}
break;
}
case Qt::TouchPointMoved: {
if (m_currentIt)
m_currentIt->touchMove(touchScenePos);
break;
}
case Qt::TouchPointReleased: {
if (m_currentIt) {
m_currentIt->untouched(touchScenePos);
m_currentIt = 0;
}
break;
}
default:
break;
}
return m_currentIt ? true : false;
} else if (te->touchPoints().count() == 2) {
if (m_currentIt) { // cancel the last touch event
m_currentIt->untouched(QPointF(0, 0));
m_currentIt = 0;
}
verticalScrollBar()->setValue(verticalScrollBar()->value() + (te->touchPoints()[0].lastPos().y() - te->touchPoints()[0].pos().y()));
return true;
}
}
}
return QGraphicsView::viewportEvent(event);
}