Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. How to filter out «back» events in a web view?

How to filter out «back» events in a web view?

Scheduled Pinned Locked Moved Qt WebKit
6 Posts 3 Posters 1.7k Views
  • 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.
  • A Offline
    A Offline
    andrey_x64
    wrote on last edited by
    #1

    Hello, all!

    I develop a form based upon QWebView (and have QWebView and QWebPage inherited for additional work). It's important that a user can press Backspace without returning to whatever page it was opened before. How do I do this in QtWebKit?

    1 Reply Last reply
    0
    • B Offline
      B Offline
      brcontainer
      wrote on last edited by
      #2

      Try:

      @bool CWebView:eventFilter( QObject pObj, QEvent event )
      {
      QKeyEvent
      pkeyEvent = (QKeyEvent
      )event;

      if (Qt::ControlModifier == pKeyEvent->state())
      {
      switch (pKeyEvent->key())
      {
      case Qt::Key_Backspace:
      //something
      break;
      default:
      return false;
      break;
      }
      }
      return true;
      }@

      QT project: https://github.com/brcontainer/qt-helper

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sandy.martel
        wrote on last edited by
        #3

        Make sure you clear the history when there's a page change.

        1 Reply Last reply
        0
        • B Offline
          B Offline
          brcontainer
          wrote on last edited by
          #4

          clear history:

          @#include <QWebHistory>

          ...

          QWebView* CWebView;
          ...
          CWebView->history()->clear();@

          Or use Javascrip-t
          http://stackoverflow.com/a/8969975/1518921

          QT project: https://github.com/brcontainer/qt-helper

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andrey_x64
            wrote on last edited by
            #5

            Guilherme, unfortunately, it appers there is no "right" way to only what I want and leave the application intact (see the answer to my "issue":https://bugreports.qt-project.org/browse/QTBUG-35555). I might call it zeroth solution.

            The first solution works only when a user is not supposed to use Backspace, the second one requires to log visited pages for navigation to work.

            We have chosen the third solution, which is to make the application single-paged.

            Anyways, thank you for your suggestions.

            [quote author="Guilherme Nascimento" date="1387234402"]clear history:

            @#include <QWebHistory>

            ...

            QWebView* CWebView;
            ...
            CWebView->history()->clear();@

            Or use Javascrip-t
            http://stackoverflow.com/a/8969975/1518921[/quote]

            1 Reply Last reply
            0
            • B Offline
              B Offline
              brcontainer
              wrote on last edited by
              #6

              and the third in javascrip-t? Try: http://stackoverflow.com/questions/20343115/how-to-filter-out-back-events-in-a-qt-web-view/20814671#20814671

              QT project: https://github.com/brcontainer/qt-helper

              1 Reply Last reply
              0

              • Login

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