Skip to content

Commit

Permalink
Fix QML plugin not being found on iOS
Browse files Browse the repository at this point in the history
When a QML plugin is used as a static library, the qml engine
searches for a qmldir in qrc:/qt-project.org/imports/<ModuleName>

This adds a qrc file to do that and ensure it is initialized for static builds.
  • Loading branch information
oKcerG committed Jan 4, 2018
1 parent 65483f5 commit 293433f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
15 changes: 11 additions & 4 deletions qml/libQmlAV.pro
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@ PROJECTROOT = $$PWD/..
preparePaths($$OUT_PWD/../out)
#https://github.com/wang-bin/QtAV/issues/368#issuecomment-73246253
#http://qt-project.org/forums/viewthread/38438
# mkspecs/features/qml_plugin.prf
URI = QtAV #uri used in QtAVQmlPlugin::registerTypes(uri)
qtAtLeast(5, 3): QMAKE_MOC_OPTIONS += -Muri=$$URI # not sure what moc does
#DESTDIR = $$BUILD_DIR/bin/QtAV
# mkspecs/features/qml_plugin.prf mkspecs/features/qml_module.prf
TARGETPATH = QtAV
URI = $$replace(TARGETPATH, "/", ".")
QMAKE_MOC_OPTIONS += -Muri=$$URI

static: CONFIG += builtin_resources

builtin_resources {
RESOURCES += libQmlAV.qrc
}

qtav_qml.files = qmldir Video.qml plugins.qmltypes
!static { #static lib copy error before ranlib. copy only in sdk_install
plugin.files = $$DESTDIR/$$qtSharedLib($$NAME)
Expand Down
6 changes: 6 additions & 0 deletions qml/libQmlAV.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<RCC>
<qresource prefix="/qt-project.org/imports/QtAV">
<file>qmldir</file>
<file>Video.qml</file>
</qresource>
</RCC>
9 changes: 9 additions & 0 deletions qml/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,22 @@
#include "QmlAV/QuickFBORenderer.h"
#endif

inline void initResources() {
#ifdef BUILD_QMLAV_STATIC
Q_INIT_RESOURCE(libQmlAV);
#endif
}

namespace QtAV {

class QtAVQmlPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
public:
QtAVQmlPlugin() {
initResources();
}
void registerTypes(const char *uri)
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("QtAV"));
Expand Down

0 comments on commit 293433f

Please sign in to comment.