I just make a MyListView class, inheriting QListView. ( from the imageguesture example code.) and enable gesture by adding grabGesture function. here below is my code. But it does not work as expected. besides, there are many debug output,telling me that the painter is not active. Thanks all.
Code:
MyListView::MyListView(QWidget *parent) :
    QListView(parent)
{
    this->grabGesture(Qt::SwipeGesture);
    this->grabGesture(Qt::PanGesture);
    this->grabGesture(Qt::PinchGesture);
}
bool MyListView::event(QEvent *event)
 {
     if (event->type() == QEvent::Gesture)
     {
         qDebug() << "Gesture Event Detected.";
         return gestureEvent(static_cast<QGestureEvent*>(event));
     }
     return QWidget::event(event);
 }
bool MyListView::gestureEvent(QGestureEvent *event)
 {
     if (QGesture *swipe = event->gesture(Qt::SwipeGesture))
     {
         qDebug() << "SwipGesture Detected.";
         swipeTriggered(static_cast<QSwipeGesture *>(swipe));
     }

     else if (QGesture *pan = event->gesture(Qt::PanGesture))
     {
            qDebug() << "PanGesture Detected.";
         panTriggered(static_cast<QPanGesture *>(pan));
     }
     /*
     else  if (QGesture *pinch = event->gesture(Qt::PinchGesture))
         pinchTriggered(static_cast<QPinchGesture *>(pinch));
       */
     return true;
 }
void MyListView::swipeTriggered(QSwipeGesture *gesture)
{
    if (gesture->state() == Qt::GestureFinished) {
        if (gesture->horizontalDirection() == QSwipeGesture::Left
            || gesture->verticalDirection() == QSwipeGesture::Up)
        {
            //goPrevImage();
            qDebug() << "UP";
            this->scroll(10,0);
        }
        else
        {
            //goNextImage();
            qDebug() << "DOWN";
            this->scroll(-10,0);

        }
        //update();
    }
}
void MyListView::panTriggered(QPanGesture *gesture)
{
#ifndef QT_NO_CURSOR
    switch (gesture->state()) {
        case Qt::GestureStarted:
        case Qt::GestureUpdated:
            setCursor(Qt::SizeAllCursor);
            break;
        default:
            setCursor(Qt::ArrowCursor);
    }
#endif
    QPointF delta = gesture->delta();
   // horizontalOffset += delta.x();
    //verticalOffset += delta.y();
    this->scroll(delta.x(),delta.y());
}