Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Smooth scrolling in QWebView on Maemo 5

From Wiki
Jump to: navigation, search
Article Metadata
Code Example
Source file: Media:Webkit2.zip
Compatibility
Platform(s):
Symbian
Article
Created: divanov (20 Apr 2010)
Last edited: hamishwillee (11 Oct 2012)

Contents

Overview

This article shows how to only scroll items on a QWebView without selecting the text.


Problem description

At the moment, finger scrolling on a QWebView does two things at the same time - scrolling and selecting text. The purpose of this article is to provide a workaround for this issue.

Solution

In order to only scroll a QWebView without selecting text, an event filter can be installed on the QWebViewobject. An event filter is an object that receives all events that are sent to the object. The filter can either stop the event or forward it to the object.

view->installEventFilter(this);

And then cancel mouse move events, when left button is pressed

bool QWebViewSelectionSuppressor::eventFilter(QObject *, QEvent *e)
{
switch (e->type()) {
case QEvent::MouseButtonPress:
if (static_cast<QMouseEvent *>(e)->button() == Qt::LeftButton)
mousePressed = true;
break;
case QEvent::MouseButtonRelease:
if (static_cast<QMouseEvent *>(e)->button() == Qt::LeftButton)
mousePressed = false;
break;
case QEvent::MouseMove:
if (mousePressed)
return true;
break;
default:
break;
}
return false;
}

The event filter filterObj receives events via its eventFilter() function. The eventFilter() function must return true if the event should be filtered, (i.e. stopped); otherwise it must return false.

Note that this is a temporary workaround until the QtWebKit bug 36109 is resolved.

Source Code

Small test application demonstrating the workaround File:Webkit2.zip

This page was last modified on 11 October 2012, at 01:18.
60 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×