IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

WebEngineScriptCollection QML Type

Manages a collection of user scripts.

This type was introduced in QtWebEngine 6.2.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

WebEngineScriptCollection QML Type

  • Import Statement: import QtWebEngine

  • Since:: QtWebEngine 6.2

Detailed Description

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.

The new user script can be instantiated with JavaScript dictionaries when using collection property.

See the following code snippets demonstrating the usage:

  • collection property with JavaScript dictionaries

     
    Sélectionnez
    var scriptFoo = { name: "Foo",
                    sourceUrl: Qt.resolvedUrl("foo.js"),
                    injectionPoint: WebEngineScript.DocumentReady }
    
    webEngineView.userScripts.collection = [ scriptFoo, scriptBar ];
  • collection property with user script object as value type

     
    Sélectionnez
    var script = WebEngine.script()
    script.name = "FOO"
    webEngineView.userScripts.collection = [ script ]
  • user script collection insert method can be used only with value type or list of value types

     
    Sélectionnez
    var script = WebEngine.script()
    script.name = "FOO"
    webEngineView.userScripts.insert(script)
    
    var list = [ script ]
    webEngineView.userScripts.insert(list)

See Also

Property Documentation

 

[since QtWebEngine 6.2] collection : list<WebEngineScript>

This property holds a JavaScript array of user script objects. The array can take WebEngineScript basic type or a JavaScript dictionary as values.

This property was introduced in QtWebEngine 6.2.

Method Documentation

 

[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] void contains(WebEngineScript script)

Checks if the specified script is in the collection.

This method was introduced in QtWebEngine 6.2.

See Also

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

See also find()

[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

See also find()

[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

See also find()

[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

See also insert()

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+