QWebEngineFindTextResult Class
QWebEngineFindTextResult 类封装了页面上的字符串搜索结果。更多
头文件: | #include <QWebEngineFindTextResult> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS WebEngineCore) target_link_libraries(mytarget PRIVATE Qt6::WebEngineCore) |
qmake: | QT += webenginecore |
在 QML 中: | FindTextResult |
属性
- activeMatch : const int
- numberOfMatches : const int
公共职能
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() 信号传递给用户。
© 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.