Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Kinetic Scrolling on QScrollarea on Android device ..
Forum Updated to NodeBB v4.3 + New Features

Kinetic Scrolling on QScrollarea on Android device ..

Scheduled Pinned Locked Moved Mobile and Embedded
5 Posts 4 Posters 6.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • p3c0P Offline
    p3c0P Offline
    p3c0
    Moderators
    wrote on last edited by
    #1

    Hello,

    I want to enable kinetic scrolling on a QScrollArea, so as per the Qt5.1 docs i used
    QScroller::grabGesture(m_scrollarea,QScroller::TouchGesture);
    But the scroll does not happen at all on the device, it works on using QScroller::LeftMouseButtonGesture.
    I have also done setAttribute(Qt::WA_AcceptTouchEvents,true) for the scrollarea.

    Any thing more that i need to enable ?

    Update:

    Kinetic scrolling using QScroller works on QListWidget.
    How to make it work on QScrollArea?

    Following is my test code:

    QScrollArea *sa = new QScrollArea(this);
    sa->setFrameStyle(QFrame::NoFrame);
    sa->setFrameShadow(QFrame::Plain);
    sa->setWidgetResizable(true);
    sa->resize(800,480);
    
    ScrollContentDialog *m_diag = new ScrollContentDialog(sa);  // Contains a loop where i add 50 QLabels
    m_diag->setMinimumSize(0,(50*30));
    m_diag->show();
    
    sa->setWidget(m_diag);
    sa->show();
    

    // QListWidget *m_list = new QListWidget(this);
    // m_list->setGeometry(0,0,800,480);
    // m_list->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
    // for (int i = 0; i < 200; ++i)
    // new QListWidgetItem(QString("This is a test text %1 %2").arg(i).arg(QString("--------").left(i % 8)), m_list);

    QAbstractScrollArea *area = qobject_cast<QAbstractScrollArea *>(sa); // Replace here m_list for QListWidget test
    QScroller::grabGesture(area->viewport(), QScroller::TouchGesture);
    

    157

    1 Reply Last reply
    0
    • A Offline
      A Offline
      AcerExtensa
      wrote on last edited by
      #2

      Please use "code" tags. It is just hard to read you test code...

      God is Real unless explicitly declared as Integer.

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vladstelmahovsky
        wrote on last edited by
        #3

        I'd recommend you to use QML for this

        1 Reply Last reply
        0
        • P Offline
          P Offline
          plinioandrade
          wrote on last edited by
          #4

          Hey everyone,
          I have the same problem here. I can't not make the QScrollArea works with gesture actions. My problem is exactly the same. I did everything like you but it isn't working. I'm using Qt 5.3.1 on Windows and a Samsung Galaxy S4 for tests. If someone found the solution, please share with us. Sincerely,

          1 Reply Last reply
          0
          • P Offline
            P Offline
            plinioandrade
            wrote on last edited by
            #5

            Hey every one. I figured out the problem. For some Reason the code
            @this->ui->scrollArea->viewport()->setAttribute(Qt::WA_AcceptTouchEvents);
            QScroller::grabGesture(this->ui->scrollArea->viewport(), QScroller::TouchGesture);
            @
            doesn’t work for QScrollArea. Then I used a class called FlickCharm [blog.qt.digia.com]. It was developed by Ariya Hidayat [blog.qt.digia.com] and it is working good now.
            Not satisfied I tried to use the QScroller again but this time with the parameter QScroller::LeftMouseButtonGesture that is:
            @QScroller::grabGesture(this->ui->scrollArea->viewport(), QScroller::LeftMouseButtonGesture);@

            and…. It works for Mouse Event and for Touch Event on my Samsumg Galaxy S4. Now I’m happy because I’m just using the native class QScroller and it’s working so good. I hope to help more people in the same situation. Sincerely.

            1 Reply Last reply
            2

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved