Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User ioricat's Avatar
    Join Date
    May 2009
    Posts
    16
    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());
    }

  2. #2
    Nokia Developer Moderator divanov's Avatar
    Join Date
    Oct 2009
    Posts
    4,326
    And does you platform support touch events?

  3. #3
    Registered User ioricat's Avatar
    Join Date
    May 2009
    Posts
    16
    Quote Originally Posted by divanov View Post
    And does you platform support touch events?
    yes, I am running the test on my Nokia E7 (Symbian^3 platform)

Similar Threads

  1. How to use a gesture api?
    By karuna. in forum Mobile Java General
    Replies: 2
    Last Post: 2011-08-17, 10:44
  2. How to enable VOIP settings in S^3
    By useryy in forum VoIP
    Replies: 8
    Last Post: 2010-11-22, 12:34
  3. Replies: 1
    Last Post: 2009-10-28, 06:17
  4. How to enable bluetooth in emulator ?
    By nadis in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2009-06-15, 16:00
  5. How to enable WLAN in E60?
    By praneet_g in forum Wired and Wireless interfaces (Closed)
    Replies: 3
    Last Post: 2006-07-03, 14:29

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved