QWebEngineHistory Class

QWebEngineHistory 表示Web引擎页面的历史记录. More...

头文件: #include <QWebEngineHistory>
qmake: QT += webenginewidgets
开始支持版本: Qt 5.4

公有函数

void back()
QWebEngineHistoryItem backItem() const
QList<QWebEngineHistoryItem> 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<QWebEngineHistoryItem> forwardItems(int maxItems) const
void goToItem(const QWebEngineHistoryItem &item)
QWebEngineHistoryItem itemAt(int i) const
QList<QWebEngineHistoryItem> items() const
QDataStream &operator<<(QDataStream &stream, const QWebEngineHistory &history)
QDataStream &operator>>(QDataStream &stream, QWebEngineHistory &history)

详细描述

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

历史记录使用 current item 的概念, 通过使用 back() 和 forward() 函数 backforward. current item 可以通过调用 currentItem() 获得, 并且历史记录中的任意项目都可以通过将其传递给 goToItem() 使其成为 current item.

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

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

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

另见 QWebEngineHistoryItemQWebEnginePage.

Member Function Documentation

void QWebEngineHistory::back()

Sets the current item to be the previous item in the history and goes to the corresponding page; that is, goes back one history item.

See also forward() and goToItem().

QWebEngineHistoryItem QWebEngineHistory::backItem() const

Returns the item before the current item in the history.

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

Returns the list of items in the backwards history list. At most maxItems entries are returned.

See also forwardItems().

bool QWebEngineHistory::canGoBack() const

Returns true if there is an item preceding the current item in the history; otherwise returns false.

See also canGoForward().

bool QWebEngineHistory::canGoForward() const

Returns true if we have an item to go forward to; otherwise returns false.

See also canGoBack().

void QWebEngineHistory::clear()

Clears the history.

See also count() and items().

int QWebEngineHistory::count() const

Returns the total number of items in the history.

QWebEngineHistoryItem QWebEngineHistory::currentItem() const

Returns the current item in the history.

int QWebEngineHistory::currentItemIndex() const

Returns the index of the current item in history.

void QWebEngineHistory::forward()

Sets the current item to be the next item in the history and goes to the corresponding page; that is, goes forward one history item.

See also back() and goToItem().

QWebEngineHistoryItem QWebEngineHistory::forwardItem() const

Returns the item after the current item in the history.

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

Returns the list of items in the forward history list. At most maxItems entries are returned.

See also backItems().

void QWebEngineHistory::goToItem(const QWebEngineHistoryItem &item)

Sets the current item to be the specified item in the history and goes to the page.

See also back() and forward().

QWebEngineHistoryItem QWebEngineHistory::itemAt(int i) const

Returns the item at index i in the history.

QList<QWebEngineHistoryItem> QWebEngineHistory::items() const

Returns a list of all items currently in the history.

See also count() and clear().

Related Non-Members

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

Saves the web engine history history into stream.

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

Loads the web engine history from stream into history.