Solution for 14.04 (Easy, QML only)
The following QML code will work on 14.04 only because it requires Qt >= 5.1
(and Trusty provides 5.2.1
).
You can have a .desktop
file containing:
Exec=/usr/bin/qmlscene %U /path/to/your/qml-app/myapp.qml
MimeType=x-scheme-handler/myapp
and use Qt.application.arguments[1]
to receive the URL content.
Solution for 13.10 (requires C++)
The .desktop file is very similar to the previous one but here qmlscene
is replaced by the name of your app:
Exec=/path/to/your/binary_app %U
MimeType=x-scheme-handler/myapp
For 13.10, you'll have to use some C++ and parse the arguments using this type of application:
#include <QtGui/QGuiApplication>
#include "qtquick2applicationviewer.h"
#include <QQmlContext>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QtQuick2ApplicationViewer viewer;
// Register the URL with the QML runtime
viewer.rootContext()->setContextProperty("url", app.arguments().at(1));
// Now, load the main page
viewer.setMainQmlFile(QStringLiteral("qml/myapp.qml"));
viewer.showExpanded();
return app.exec();
}
You'll be able to get the url from QML thanks to setContextProperty().
Visit Embedding C++ Objects into QML with Context Properties for further details.