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. Thanks for all your past and future contributions.

Using QWebHistory to navigate through web pages

From Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Tested on Nokia 5800 XpressMusic,
Nokia N97
Platform(s): S60 5th Edition
S60 5th Edition
Keywords: QWebHistory, QWebView
Created: User:Kbwiki (24 Mar 2010)
Last edited: hamishwillee (11 Oct 2012)


An instance of the QWebHistory class can be used to navigate through the history of web pages, displayed using QWebView.


The following code snippet shows how to use the QWebHistory class to move back or forward through web history items.

 #include <QWebView>
#include <QWebHistory>
WebMainView::WebMainView( QWidget *parent )
: QMainWindow( parent )
web = new QWebView();
QVBoxLayout *layout = new QVBoxLayout();
web->setLayout( layout );
setCentralWidget( web );
// Retrieve and store a pointer to QWebHistory
m_wHistory = web->history();
web->load( QUrl( "" ) );
// (slot): move back to the last history item
void WebMainView::Back()
if ( m_wHistory->canGoBack() ) {
// (slot): move forward by one history item
void WebMainView::Forward()
if ( m_wHistory->canGoForward() ) {
This page was last modified on 11 October 2012, at 01:18.
48 page views in the last 30 days.