diff options
| author | Michal Klocek <michal.klocek@qt.io> | 2025-09-15 13:49:30 +0200 |
|---|---|---|
| committer | Michal Klocek <michal.klocek@qt.io> | 2025-10-28 12:59:04 +0200 |
| commit | 0e40da3e1bbb558f1c416f0965502e42919db7da (patch) | |
| tree | 1da93bee20068a292dfbf9d0611b0e241faa07b3 /src/webenginequick | |
| parent | 21ca55da00e7c4f1cf85f96b4e75085032241f56 (diff) | |
Add chlid frame to qml api of webengineframe
It seems that children property was overlooked.
Add it so it is posible to crawl the frame tree.
Pick-to: 6.10
Change-Id: Ie4e13ccbc695a4db3782ce2c993c74ebb3d1cc9a
Reviewed-by: Moss Heim <moss.heim@qt.io>
Diffstat (limited to 'src/webenginequick')
| -rw-r--r-- | src/webenginequick/api/qquickwebengineframe.cpp | 11 | ||||
| -rw-r--r-- | src/webenginequick/api/qquickwebengineframe_p.h | 2 | ||||
| -rw-r--r-- | src/webenginequick/doc/src/webengineframe.qdoc | 8 |
3 files changed, 21 insertions, 0 deletions
diff --git a/src/webenginequick/api/qquickwebengineframe.cpp b/src/webenginequick/api/qquickwebengineframe.cpp index 44476e31b..8bab7952e 100644 --- a/src/webenginequick/api/qquickwebengineframe.cpp +++ b/src/webenginequick/api/qquickwebengineframe.cpp @@ -23,6 +23,17 @@ QQuickWebEngineFrame::QQuickWebEngineFrame( { } +QList<QQuickWebEngineFrame> QQuickWebEngineFrame::children() const +{ + auto adapter = m_adapter.lock(); + if (!adapter) + return QList<QQuickWebEngineFrame>(); + QList<QQuickWebEngineFrame> result; + for (auto childId : adapter->frameChildren(m_id)) + result.push_back(QQuickWebEngineFrame{ m_adapter, childId }); + return result; +} + void QQuickWebEngineFrame::runJavaScript(const QString &script, const QJSValue &callback) { QWebEngineFrame::runJavaScript(script, QWebEngineScript::MainWorld, callback); diff --git a/src/webenginequick/api/qquickwebengineframe_p.h b/src/webenginequick/api/qquickwebengineframe_p.h index a4fb64ecc..9d7173e1e 100644 --- a/src/webenginequick/api/qquickwebengineframe_p.h +++ b/src/webenginequick/api/qquickwebengineframe_p.h @@ -26,6 +26,7 @@ QT_BEGIN_NAMESPACE class QQuickWebEngineFrame : public QWebEngineFrame { Q_GADGET_EXPORT(Q_WEBENGINEQUICK_EXPORT) + Q_PROPERTY(QList<QQuickWebEngineFrame> children READ children CONSTANT REVISION(6, 10) FINAL) QML_VALUE_TYPE(webEngineFrame) QML_ADDED_IN_VERSION(6, 8) QML_FOREIGN(QWebEngineFrame) @@ -38,6 +39,7 @@ public: Q_WEBENGINEQUICK_EXPORT Q_INVOKABLE void runJavaScript(const QString &script, quint32 worldId, const QJSValue &callback); Q_WEBENGINEQUICK_EXPORT Q_INVOKABLE void printToPdf(const QJSValue &callback); + QList<QQuickWebEngineFrame> children() const; private: friend class QQuickWebEngineView; diff --git a/src/webenginequick/doc/src/webengineframe.qdoc b/src/webenginequick/doc/src/webengineframe.qdoc index daa6aad23..eae2aa6f8 100644 --- a/src/webenginequick/doc/src/webengineframe.qdoc +++ b/src/webenginequick/doc/src/webengineframe.qdoc @@ -73,6 +73,14 @@ */ /*! + \qmlproperty list<webEngineFrame> webEngineFrame::children + \since QtWebEngine 6.10 + Returns a list of the frame's children in an arbitrary order. + + If the frame could not be found, returns an empty list. +*/ + +/*! \qmlmethod void webEngineFrame::runJavaScript(string script, variant callback) \qmlmethod void webEngineFrame::runJavaScript(string script, uint worldId, variant callback) |
