QWebEngineFindTextResult Class

QWebEngineFindTextResult 类封装了页面上的字符串搜索结果。更多

头文件: #include <QWebEngineFindTextResult>
CMake: find_package(Qt6 REQUIRED COMPONENTS WebEngineCore)
target_link_libraries(mytarget PRIVATE Qt6::WebEngineCore)
qmake: QT += webenginecore
在 QML 中: FindTextResult

属性

公共职能

int activeMatch() const
int numberOfMatches() const

详细说明

字符串搜索可通过QWebEnginePage::findText() 或WebEngineView.findText() 方法启动。搜索结果会在视图中突出显示。搜索结果的详细信息将作为 QWebEngineFindTextResult 对象传递,该对象可用于显示状态信息,如 "2 of 2 matches"。例如

QObject::connect(view.page(), &QWebEnginePage::findTextFinished, [](const QWebEngineFindTextResult &result) {    qInfo() << result.activeMatch() << "of" << result.numberOfMatches() << "matches";
});

结果通过QWebEnginePage::findTextFinished() 和WebEngineView.findTextFinished() 信号传递给用户。

属性文档

[read-only] activeMatch : const int

该属性保存当前高亮显示匹配的索引。

访问功能:

int activeMatch() const

[read-only] numberOfMatches : const int

该属性包含找到的匹配数。

访问功能:

int numberOfMatches() const

© 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.