Using QWebHistory to navigate through web pages

From Qt Wiki
Jump to navigation Jump to search

Template:ArticleMetaData

Description[edit | edit source]

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

Solution[edit | edit source]

The following code snippet shows how to use the 76ytuiytuityutyutututyutyutyu 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();
   }
 }