Manages a collection of user scripts. More...
| Import Statement: | import QtWebEngine
|
| Since: | QtWebEngine 6.2 |
(since QtWebEngine 6.2)
(since QtWebEngine 6.2)
(since QtWebEngine 6.2)
(since QtWebEngine 6.2)
(since QtWebEngine 6.2)
(since QtWebEngine 6.2)
(since QtWebEngine 6.2)
WebEngineScriptCollection handles a user scripts collection, which is injected in the JavaScript engine during the loading of web content.
Use WebEgineView.userScripts and WebEngineProfile.userScripts to access the collection of scripts associated with a single page or number of pages sharing the same profile.
The collection of user script objects in QML can be created for a set of user script objects by simple assignment to WebEngineScriptCollection.collection property or by WebEngineScriptCollection methods.
Note: The new user script can be instantiated with JavaScript dictionaries when using collection property.
See the following code snippets demonstrating the usage:
var scriptFoo = { name: "Foo",
sourceUrl: Qt.resolvedUrl("foo.js"),
injectionPoint: WebEngineScript.DocumentReady }
webEngineView.userScripts.collection = [ scriptFoo, scriptBar ];var script = WebEngine.script() script.name = "FOO" webEngineView.userScripts.collection = [ script ]
var script = WebEngine.script() script.name = "FOO" webEngineView.userScripts.insert(script) var list = [ script ] webEngineView.userScripts.insert(list)
See also webEngineScript and WebEngineScriptCollection.
collection : list<webEngineScript> [since QtWebEngine 6.2]
This property holds a QML list of user webEngineScript values. The list can take webEngineScript value type or a JavaScript dictionary as values.
This property was introduced in QtWebEngine 6.2.
[since QtWebEngine 6.2] void clear()
Removes all script objects from this collection.
This method was introduced in QtWebEngine 6.2.
[since QtWebEngine 6.2] bool contains(webEngineScript script)
Returns true if the specified script is in the collection, false otherwise.
This method was introduced in QtWebEngine 6.2.
See also find().
[since QtWebEngine 6.2] list<webEngineScript> find(string name)
Returns a list of all user script objects with the given name.
This method was introduced in QtWebEngine 6.2.
See also contains().
[since QtWebEngine 6.2] void insert(list<webEngineScript> list)
Inserts a list of webEngineScript values into the user script collection.
This method was introduced in QtWebEngine 6.2.
See also remove().
[since QtWebEngine 6.2] void insert(webEngineScript script)
Inserts a single script into the collection.
This method was introduced in QtWebEngine 6.2.
See also remove().
[since QtWebEngine 6.2] bool remove(webEngineScript script)
Returns true if a given script is removed from the collection.
This method was introduced in QtWebEngine 6.2.
See also insert().
© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-6.9/qml-qtwebengine-webenginescriptcollection.html