Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    Qt WebKit
    3
    6
    1365
    Loading More Posts
    • 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
      andrey_x64 last edited by

      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 Reply Quote 0
      • B
        brcontainer last edited by

        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 Reply Quote 0
        • S
          sandy.martel last edited by

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

          1 Reply Last reply Reply Quote 0
          • B
            brcontainer last edited by

            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 Reply Quote 0
            • A
              andrey_x64 last edited by

              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 Reply Quote 0
              • B
                brcontainer last edited by

                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 Reply Quote 0
                • First post
                  Last post