Managing browser history

Qt's web engine stores all the links which the user has visited into an array structure for later use. The web view widget uses this to move back and forth between history by calling back() and forward().

If you need to manually access this browsing history, add the following header to mainwindow.h:

#include <QWebEnginePage> 

After that, use the following code to obtain the browsing history in the form of a QWebEngineHistory object:

QWebEngineHistory* history = QWebEnginePage::history(); 

You can get the entire list of visited links from history->items() or navigate between history using functions such as back() or forward(). To clear the browsing history, call history->clear(). Alternatively, you can also do this: ...

Get Hands-On GUI Programming with C++ and Qt5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.