Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can I disable scroll in QWebView?
Forum Updated to NodeBB v4.3 + New Features

How can I disable scroll in QWebView?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.7k 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.
  • T Offline
    T Offline
    thebeast44
    wrote on 2 Jun 2014, 07:47 last edited by
    #1

    Hi all,

    I have a QWebView with contents stretching horizontally in numerous columns
    and I want to show those columns page by page like a book.

    What I've done so far is to override most key events and mouse events to trigger
    a custom function to scroll to specific x position.

    I've disabled most scenarios of scrolling except for 'click and drag across the border of webview'.

    @
    virtual bool event(QEvent *event)
    @
    doesn't seem to catch QEvent::Scroll so I went ahead and created an event filter

    @
    bool FilterObject::eventFilter(QObject *object, QEvent *event) {
    if (event->type() == QEvent::Scroll) {
    qDebug() << "Scroll";
    object->dumpObjectInfo();
    return true;
    }
    return false;
    }
    @

    and installed it to:

    1. QWebView
    2. QWebPage
    3. QWebPage->view()
    4. QWebPage->mainFrame()

    but none of the above seemed to react to the filter.

    I even implemented window.onscroll in JS but it happens after the scroll has already happened,
    resulting in movement sideways.

    Any idea on how I can disable scroll?

    • I need to be able to select text displayed in the view,
      so I cannot set '-webkit-user-select: none;'
    1 Reply Last reply
    0
    • T Offline
      T Offline
      thebeast44
      wrote on 2 Jun 2014, 09:04 last edited by
      #2

      I came up with temporary solution

      @
      void ViewerClass::mouseMoveEvent(QMouseEvent *event) {
      QPoint pos = event->pos();
      int width = this->contentsRect().width();
      if (pos.x() > 20 && pos.x() < width - 20) {
      QWebView::mouseMoveEvent(event);
      }
      }
      @

      Any suggestion would be greatly appreciated. Thank you.

      1 Reply Last reply
      0

      1/2

      2 Jun 2014, 07:47

      • Login

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