Namespaces
Variants
Actions

Using QWebHistory to navigate through web pages

Jump to: navigation, search
Article Metadata

Tested with
Devices(s): Tested on Nokia 5800 XpressMusic,
Nokia N97

Compatibility
Platform(s): 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 04:18.
128 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved