Web Plugins

• Sep 1, 2012 - 17:34

This is a quite technical post, I hesitated between the developer mailing list and here but finally decided to post here. If you have no interest in Qt, you probably don't want to read the following

I mentioned a couple of time that I would like to see a way to access score elements from the web browser included in MuseScore, now for MuseScore connect and for QML plugin help.

The standard technology to make it happen is named QtWebkit Bridge. You can expose existing objects, and you can access their Qt properties, signal, slots and Q_INVOKABLE methods. There are however several limitations.

- The properties cannot be child of QObject or you will not be able to access the "properties of the properties". To make it clear, if we expose the MuseScore object as mscore, and make Score* MuseScore::currentScore() Q_INVOKABLE, Javascript will not have access to the properties of the score object. But if we create a new Q_INVOKABLE method QObject* MuseScore::currentScore(), then it's working and you can write the following code in a HTML page .

alert(mscore.currentScore().name)

In Qt doc words, "If the type specified is a pointer to a non-QWidget subclass of QObject, the QtWebKit bridge would not recognize it to be a QObject."
This is quite a big limitation if we want the QML and web framework to live together... For example newCursor() should send back a QObject*. Any properties with a type should be changed to QObject*...

- Another limitation, there is no way to create QObject directly from javascript in QWebView.

- Performance is still unknown...

There are other approach to create a bridge between C++ and HTML in a webview.
See:
http://labs.qt.nokia.com/2011/08/31/an-oldnew-approach-to-qtwebkit-hybr…

Do you still have an unanswered question? Please log in first to post your question.