QWebEngineHistory class

QWebEngineHistory类表示Web引擎页面的历史记录。

属性 方法
头文件 #include
qmake参数 QT + = webenginewidgets

该类在Qt 5.4中引入。

公有成员函数

类型 方法
void back()
QWebEngineHistoryItem backItem() const
QList backItems(int maxItems) const
bool canGoBack() const
bool canGoForward() const
void clear()
int count() const
QWebEngineHistoryItem currentItem() const
int currentItemIndex() const
void forward()
QWebEngineHistoryItem forwardItem() const
QList forwardItems(int maxItems) const
void goToItem(const QWebEngineHistoryItem &item)
QWebEngineHistoryItem itemAt(int i) const
QList items() const

相关非成员函数

类型 方法
QDataStream & operator<<(QDataStream &stream, const QWebEngineHistory &history)
QDataStream & operator>>(QDataStream &stream, QWebEngineHistory &history)

详细描述

成员函数文档

每个Web引擎页面都包含访问过的页面的历史记录,可以由QWebEnginePage::history()得到。

历史记录使用当前项目的概念,通过使用back() 和 forward()函数来回导航,将访问的页面划分为可以访问的页面。 当前项目可以通过调用 currentItem()获得,并且历史记录中的任意项目都可以通过将其传递给goToItem()使其成为当前项目。

可以通过调用backItems()函数获得描述可以返回的页面的项目列表。类似的,可以使用forwardItems()函数获得描述当前页面之前页面的项目。 项目的总列表是通过 items()函数获得的。

与容器一样,可以使用函数来检查列表中的历史记录。可以使用itemAt()获得历史记录中的任意项目,通过 count()给出项目的总数,并可以使用 clear() 函数清除历史记录。

可以使用>>运算符将QWebEngineHistory的状态保存到QDataStream 中,并使用<<操作符进行加载。

另外参见 QWebEngineHistoryItem and QWebEnginePage

成员函数文档

void QWebEngineHistory::back()

将当前项目设置为历史记录中的前一个项目,然后转到相应页面; 也就是说,返回一个历史项目。

See also forward() and goToItem().

QWebEngineHistoryItem QWebEngineHistory::backItem() const

返回历史记录中当前项目之前的项目。

QList<QWebEngineHistoryItem> QWebEngineHistory::backItems(int maxItems) const

返回向后历史记录列表中的项目列表。 最多返回maxItems条目。

See also forwardItems()。

bool QWebEngineHistory::canGoBack() const

如果历史记录中当前项目之前有一个项目,则返回true, 否则返回false

See also canGoForward()。

bool QWebEngineHistory::canGoForward() const

如果我们有一个项目可以前进,则返回true,否则返回false

See also canGoBack()。

void QWebEngineHistory::clear()

清除历史记录。

See also count() and items()。

int QWebEngineHistory::count() const

返回历史记录中的项目总数。

QWebEngineHistoryItem QWebEngineHistory::currentItem() const

返回历史记录中的当前项目。

int QWebEngineHistory::currentItemIndex() const

返回历史记录中当前项目的索引。

void QWebEngineHistory::forward()

将当前项目设置为历史记录中的下一个项目,然后转到相应页面; 即,前进一个历史项目。

See also back() and goToItem()。

QWebEngineHistoryItem QWebEngineHistory::forwardItem() const

返回历史记录中当前项目之后的项目。

QList<QWebEngineHistoryItem> QWebEngineHistory::forwardItems(int maxItems) const

返回转发历史记录列表中的项目列表。 最多返回maxItems条目。

See also backItems().

void QWebEngineHistory::goToItem(const QWebEngineHistoryItem &item)

将当前项目设置为历史记录中的指定项目,然后转到页面。

See also back() and forward()。

QWebEngineHistoryItem QWebEngineHistory::itemAt(int i) const

返回历史记录中索引i处的项目。

QList<QWebEngineHistoryItem> QWebEngineHistory::items() const

返回历史记录中当前所有项目的列表。

See also count() and clear()。

相关非成员函数

QDataStream &operator<<(QDataStream &stream, const QWebEngineHistory &history)

将Web引擎历史记录历史记录保存到流中。

QDataStream &operator>>(QDataStream &stream, QWebEngineHistory &history)

将Web引擎历史记录从流加载到历史记录中。