本文整理汇总了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();
//.........这里部分代码省略.........