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. 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
Compatibility
Platform(s): S60 5th Edition
Symbian
S60 5th Edition
Article
Keywords: QWebHistory, QWebView
Created: User:Kbwiki (24 Mar 2010)
Last edited: hamishwillee (11 Oct 2012)

Description

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

Solution

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( "http://www.ovi.mobi" ) );
}
 
 
// (slot): move back to the last history item
void WebMainView::Back()
{
if ( m_wHistory->canGoBack() ) {
m_wHistory->back();
}
}
 
 
// (slot): move forward by one history item
void WebMainView::Forward()
{
if ( m_wHistory->canGoForward() ) {
m_wHistory->forward();
}
}
This page was last modified on 11 October 2012, at 01:18.
48 page views in the last 30 days.
×