WebEngineHistory QML Type
ウェブエンジンページの履歴を表すデータモデルを提供する。詳細...
Import Statement: | import QtWebEngine |
Since: | QtWebEngine 1.1 |
In C++: | QWebEngineHistory |
プロパティ
- backItems : WebEngineHistoryModel
- forwardItems : WebEngineHistoryModel
- items : WebEngineHistoryModel
方法
- void clear()
(since QtWebEngine 1.11)
詳細説明
WebEngineHistory 型には、WebEngineView.history プロパティを使用してアクセスできます。
WebEngineHistory 型は、次のWebEngineHistoryModel データ モデル オブジェクトを提供します:
backItems
訪問したページの URL が格納されています。forwardItems
現在のページを訪問した後に訪問したページの URL が格納されています。items
これは、現在のページのURLと同様に、戻る項目と進む項目のURLを含んでいます。
これらのモデルを使用する最も簡単な方法は、次のコード・スニペットで示すように、ListView :
ListView { id: historyItemsList anchors.fill: parent model: webEngineView.history.items delegate: Text { color: "black" text: model.title + " - " + model.url + " (" + model.offset + ")" } }
ListView 、対応するモデルの内容が表示されます。デリゲートは、リスト項目のフォーマットを担当します。デリゲートにおけるリストの各項目の外観は、個別に定義することができます(ウェブエンジン固有のものではありません)。
モデルのtitle、url、iconの役割は、訪問したページのタイトル、URL、ファビコンを指定します。offsetロールは、現在のページ(0)に対するページの位置を指定します。正の数は、ページが現在のページの後に訪問されたことを示し、負の数は、ページが現在のページの前に訪問されたことを示します。
以下のコードスニペットに示すように、データモデルを使用してメニューを作成することもできます:
menuBar: ToolBar { id: navigationBar RowLayout { anchors.fill: parent ToolButton { enabled: currentWebView && (currentWebView.canGoBack || currentWebView.canGoForward) onClicked: historyMenu.open() text: qsTr("▼") Menu { id: historyMenu Instantiator { model: currentWebView && currentWebView.history.items MenuItem { text: model.title onTriggered: currentWebView.goBackOrForward(model.offset) checkable: !enabled checked: !enabled enabled: model.offset } onObjectAdded: function(index, object) { historyMenu.insertItem(index, object) } onObjectRemoved: function(index, object) { historyMenu.removeItem(object) } } }
完全な例については、WebEngine Quick Nano Browser を参照してください。
WebEngineHistoryModelも参照して ください。
プロパティの説明
backItems : WebEngineHistoryModel |
訪問したページの URL。
forwardItems : WebEngineHistoryModel |
現在のページにアクセスした後にアクセスしたページの URL。
items : WebEngineHistoryModel |
履歴の戻る項目、進む項目、現在の項目の URL。
メソッド・ドキュメント
|
履歴を消去します。
このメソッドは QtWebEngine 1.11 で導入されました。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.