Solved QScrollarea and touch
-
I want use the QScrollarea on a tablet. There are 2 main problems.
- Touch-Scrolling works only with 2 fingers.
Is there a way to enable 1 finger scrolling for the scroll area to give it a consistent GUI for QML/Widget mixed apps. - If I touch with 2 fingers on a QPushButton, scroll and then lift my fingers I get a clickEvent from the button, but I want only scrolling.
Is there a solution for the problem ?
- Touch-Scrolling works only with 2 fingers.
-
@Andy314
I'm not sure if the following snippet solves your problem since I have no display near by - but in a project some years ago I setup the scrollArea as followed. Just try - and forget my conment if it does not work... ;-)// hide scrollbars scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // configure gesture and add rubberband effect QScroller::grabGesture(scrollArea, QScroller::LeftMouseButtonGesture);
-
Hello @micland,
wow, it works and is so simple. Qt surprises again, there are certainly much more feature of Qt I dont know.
Thank you very much for this tip, it solves a lot of problem for my project. :-)
-
@Andy314
Fine, you're welcome :)
I remember I had a similiar problem years ago and found that snippet in one of the examples - but I was not sure if my problem was exactly the same that you had. Seems so... -
Have you tried using QScroller::grabGesture(scrollArea, QScroller::LeftMouseButtonGesture); on a QWidgets application with multiple QScrollAreas?
Has that presented any problems for you?