PDA

View Full Version : QScroller with QWebView



wil23423423
23rd February 2016, 02:14
Hello,

I'm having an issue getting touch screen scrolling to work in a QWebView with Qt 5.5 and QtWebKit. It only seems to allow scrolling in the scroll bar, if you scroll in the page as you would on a smart phone, it selects text instead of scrolling.

I have tried using the scroller/plot example in webkitwidgets and with it, the QListWidget page scrolls as expected, but the QWebView page has the same issue.

I dont know if this is the expected operation or not, if so, is there a way to get QWebView to perform scrolling across the whole page and not just the scroll bar?

Thanks,
Will.

wil23423423
24th February 2016, 06:55
The issue I was having was fixed by making these changes:

QGraphicsView view;
QGraphicsWebView webview;
QGraphicsScene scene;
...
webview.setResizesToContents(true);
webview.page()->setPreferredContentsSize(QSize(SCREEN_WIDTH, SCREEN_HEIGHT));

...
view.setScene(&scene);
scene.addItem(&webview);

QScroller::grabGesture(&view, QScroller::LeftMouseButtonGesture);

Will.