Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    how to enable the QListWidget support touch event

    Mobile and Embedded
    6
    10
    7279
    Loading More Posts
    • 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.
    • X
      xhsoldier last edited by

      As the title.
      Do not use the scroll bar to navigate the item, but just touch the screen to scroll up and down.

      Or any other options to implement a list that support touch?(not qml)

      1 Reply Last reply Reply Quote 0
      • M
        mohsen last edited by

        re-implement a QListWidget class with mouseMove, mouseRelease and mousePress events

        1 Reply Last reply Reply Quote 0
        • X
          xhsoldier last edited by

          Yes. I do the same. stupid.

          1 Reply Last reply Reply Quote 0
          • C
            chriadam last edited by

            Do you have to use a QListWidget? If you can use QML instead, try a flickable element.
            /edit: hrm, I clearly didn't read your question thoroughly; you said you can't use QML.

            1 Reply Last reply Reply Quote 0
            • A
              andre last edited by

              Perhaps you should also look for the "flick charm" that was written a few years ago. It could still serve to inspire you.

              1 Reply Last reply Reply Quote 0
              • M
                mbnoimi last edited by

                I stucked with this issue since months ago :(

                May some one help us here and contribute with small snippet?

                1 Reply Last reply Reply Quote 0
                • L
                  ltr6 last edited by

                  Try QScroller:

                  http://qt-project.org/doc/qt-5/qscroller.html

                  This might also help:

                  http://qt-project.org/forums/viewthread/38529

                  1 Reply Last reply Reply Quote 0
                  • M
                    mbnoimi last edited by

                    [quote author="ltr6" date="1399363630"]Try QScroller:

                    http://qt-project.org/doc/qt-5/qscroller.html

                    This might also help:

                    http://qt-project.org/forums/viewthread/38529[/quote]

                    Thank you; but I really didn't understand how can I make my QListWidget supports Touch. I really need some simple snippet.

                    1 Reply Last reply Reply Quote 0
                    • L
                      ltr6 last edited by

                      There was a snippet, I'll paste it here:

                      @QScrollerProperties sp;

                      sp.setScrollMetric(QScrollerProperties::DragVelocitySmoothingFactor, 0.6);
                      sp.setScrollMetric(QScrollerProperties::MinimumVelocity, 0.0);
                      sp.setScrollMetric(QScrollerProperties::MaximumVelocity, 0.5);
                      sp.setScrollMetric(QScrollerProperties::AcceleratingFlickMaximumTime, 0.4);
                      sp.setScrollMetric(QScrollerProperties::AcceleratingFlickSpeedupFactor, 1.2);
                      sp.setScrollMetric(QScrollerProperties::SnapPositionRatio, 0.2);
                      sp.setScrollMetric(QScrollerProperties::MaximumClickThroughVelocity, 0);
                      sp.setScrollMetric(QScrollerProperties::DragStartDistance, 0.001);
                      sp.setScrollMetric(QScrollerProperties::MousePressEventDelay, 0.5);

                      QScroller* scroller = QScroller::scroller(yourListWidget);

                      scroller->grabGesture(yourListWidget, QScroller::LeftMouseButtonGesture);

                      scroller->setScrollerProperties(sp);@

                      On lines 13 and 15 you need to give your list widget as the parameter.

                      1 Reply Last reply Reply Quote 0
                      • M
                        mbnoimi last edited by

                        Thank you a lot; I didn't expect it very easy. I thought the pointed code works for scrolling only.

                        xhsoldier. May you please set this thread as [SOLVED]

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post