WebEngineHistory QML Type

웹 엔진 페이지의 기록을 나타내는 데이터 모델을 제공합니다. 더 보기...

Import Statement: import QtWebEngine
Since: QtWebEngine 1.1
In C++: QWebEngineHistory

속성

방법

  • void clear() (since QtWebEngine 1.11)

상세 설명

WebEngineHistory 유형은 WebEngineView.history 속성을 사용하여 액세스할 수 있습니다.

WebEngineHistory 유형은 다음과 같은 WebEngineHistoryModel 데이터 모델 객체를 제공합니다:

  • backItems는 방문한 페이지의 URL을 포함합니다.
  • forwardItems현재 페이지를 방문한 후 방문한 페이지의 URL이 포함된 , , 현재 페이지를 방문한 후 방문한 페이지의 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 은 해당 모델의 콘텐츠를 표시합니다. 델리게이트는 목록 항목의 형식을 담당합니다. 델리게이트에서 목록의 각 항목의 모양은 별도로 정의할 수 있습니다(웹 엔진별로 다르지 않음).

모델 역할 제목, URL아이콘은 방문한 페이지의 제목, URL 및 파비콘을 지정합니다. 오프셋 역할은 현재 페이지(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)
                        }
                    }
                }

전체 예제는 웹엔진 퀵 나노 브라우저를 참조하세요.

WebEngineHistoryModel참조하세요 .

속성 문서

backItems : WebEngineHistoryModel [read-only]

방문한 페이지의 URL.


forwardItems : WebEngineHistoryModel [read-only]

현재 페이지를 방문한 후 방문한 페이지의 URL입니다.


items : WebEngineHistoryModel [read-only]

기록에서 뒤로 항목, 앞으로 항목 및 현재 항목의 URL.


메서드 문서

[since QtWebEngine 1.11] void clear()

기록을 지웁니다.

이 메서드는 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.