Module "PlayRawPlugIn" is not installed - qt

I'm trying to integrate a QML Plugin in a qt project but I get: module "PlayRawPlugIn" is not installed import PlayRawPlugIn 1.0
The structure of my application is:
player.pro
--playerInterface.pro
--PlayRawPlugIn.pro
player.pro
TEMPLATE = subdirs
CONFIG += ORDERED
SUBDIRS += playerInterface
SUBDIRS += playrawplugin
Can you tell me what I'm doing wrong?
Many thanks!!

Related

Including QML plugin into project

I have a QML plugin project and my application project plus subdirs project organized like that:
project.pro
plugin/
plugin.pro
Plugin.cpp
Plugin.h
qmldir
app/
app.pro
main.cpp
main.qml
qml.qrc
project.pro:
TEMPLATE = subdirs
SUBDIRS = app plugin
app.depends = plugin
plugin.pro:
TEMPLATE = lib
QT += qml quick
CONFIG += plugin c++11
TARGET = $$qtLibraryTarget(plugin)
PLUGIN_URI = com.test.plugin
SOURCES += Plugin.cpp
HEADERS += Plugin.h
app.pro:
QT += qml quick
SOURCES += main.cpp
RESOURCES += qml.qrc
It builds as expected and now I need to pass path to compiled libplugin.dylib/.so/.dll and qmldir to my application. I see two ways:
Copy plugin files into /path/to/qt/5.10.1/clang_64/qml/com/test/plugin/ using INSTALL qmake variable.
Copy plugin files near the application executable and add this path as relative to the executable using QQmlEngine::addImportPath().
What approach will be better? How to do it?

qmake, build producing a custom library name

I have a .pro file named XYZ.pro. Here is it.
QT += core gui
TARGET = XYZ
TEMPLATE = lib
CONFIG += plugin
DESTDIR = $$[QT_INSTALL_PLUGINS]/generic
SOURCES += cc.cpp
HEADERS += cc.h
DISTFILES += XYZ.json
I want the build to product a library ABC.o.
How do I do this?
TARGET = ABC
And make sure qmake is re-run after the change.

What is the proper way of deploying C++ QML plugins on mobile device?

I've been playing a lot with the Box2D QML plugin and the things are looking really good.
However, I wanted to deploy my sample app on Android (SGS2), but I can't seem to get it work. Whether I try to run it on AVD or on the device, it doesn't work. androiddeployqt finishes successfully, but then I get "Unable to start 'MyApp'" and no other info as to why it failed to start. I can successfully run qml apps on the AVD and the device, but this has something to do with the plugin and I can't find any reference in order to solve it.
I tried setting up DEPLOYMENTFOLDERS in different ways, but if i get them wrong, then the whole thing fails. Even when I don't get an error, in which case I assume I got it right, it still doesn't start.
I've been struggling with this for quiet some time, and can't find any bit of useful information in order to resolve it.
If you know of any project that uses a c++ plugin and can be successfully deployed on android device, that would be good as well.
I am using Qt 5.2.0 compiled for android and the qt5 branch of box2d
We were getting "module not found" errors while we were trying to get our QML module working inside an Android Qt application. With Qt 5.3, we managed to get our QML plugin recognized only by deploying the plugin to the QT_INSTALL_QML directory where official Qt QML modules reside. This directory is /opt/Qt/5.3/android_armv7/qml in our case.
Plugin Side
Our .pro file for the plugin looks like:
TEMPLATE = lib
TARGET = prova
QT += qml quick multimedia
CONFIG += qt plugin c++11 console
CONFIG -= android_install
TARGET = $$qtLibraryTarget($$TARGET)
uri = com.mycompany.qmlcomponents
# Input
SOURCES += \
src1.cpp \
src2.cpp
HEADERS += \
src1.h \
src2.h
##The below is generated automatically by Qt Creator when you create a new "Qt Quick 2 Extension Plugin" project for Android
#Copies the qmldir file to the build directory
!equals(_PRO_FILE_PWD_, $$OUT_PWD) {
copy_qmldir.target = $$OUT_PWD/qmldir
copy_qmldir.depends = $$_PRO_FILE_PWD_/qmldir
copy_qmldir.commands = $(COPY_FILE) \"$$replace(copy_qmldir.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_qmldir.target, /, $$QMAKE_DIR_SEP)\"
QMAKE_EXTRA_TARGETS += copy_qmldir
PRE_TARGETDEPS += $$copy_qmldir.target
}
#Copies the qmldir file and the built plugin .so to the QT_INSTALL_QML directory
qmldir.files = qmldir
unix {
installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /)
qmldir.path = $$installPath
target.path = $$installPath
INSTALLS += target qmldir
}
Our qmldir (in the plugin source tree root) file is:
module com.mycompany.qmlcomponents
plugin prova
Application Side
The .pro file looks like:
TEMPLATE = app
QT += qml quick widgets multimedia
CONFIG+= console
SOURCES += main.cpp
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Default rules for deployment.
include(deployment.pri)
contains(ANDROID_TARGET_ARCH,armeabi-v7a) {
ANDROID_EXTRA_LIBS = \
/opt/Qt/5.3/android_armv7/qml/com/mycompany/qmlcomponents/libprova.so
}
Important Note: Any library that your qml plugin uses must also be listed in ANDROID_EXTRA_LIBS in order to be bundled into the apk. This includes Qt components as well, listing them in QT+= is not enough if you don't use them in your application.
We don't actually know if the inclusion of the extra libprova.so is necessary. It's most probably not.
The main.cpp looks like:
#include <QApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[]){
QApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
return app.exec();
}
The main.qml just includes the plugin like:
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtMultimedia 5.0
import com.mycompany.qmlcomponents 1.0
...
Building and Deployment
The way we build and deploy the plugin is to qmake (from the android-armv7 toolchain of Qt), then make install. It installs the qmldir file and the plugin .so to the QT_INSTALL_QML directory.
The way we build and deploy the project that uses the plugin is to qmake (again, from the android-armv7 toolchain of Qt), then make install INSTALL_ROOT=. (installs to build directory), then run androiddeployqt. The last command creates the Android project structure with the qmldirs in assets/ and libraries in libs/ and bundles the whole thing in an apk via ant. For the details of this procedure, refer to http://qt-project.org/wiki/Android.
In short, we were only able to get our QML plugin recognized inside an Android project by putting it inside the private Qt qml directory. I hope this helps in some way.

Setup SUBDIRS template failed in QtCreator

The project is application(.pro) with a static library(.pro), so I am going to use TEMPLATE = SUBDIRS to manage it.
my workspace.pro
TEMPLATE = SUBDIRS
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
SUBDIRS += \
MY_LIB \
MY_APP1
MY_LIB.file=/Users/username/MYLIB/mylib.pro
MY_APP1.file=/Users/username/MYAPP/App1/App1.pro
The workspace.pro file is in /Users/username/MYAPP/ directory.
When I tried to build it, QtCreator gave error
WARNING: Unable to generate output for: /Users/username/MYAPP/build-workspace_Qt_5_1_0_clang_64bit-Debug/Makefile [TEMPLATE SUBDIRS]
May I know how to solve it? and why it happen? Thanks.
It should be TEMPLATE = subdirs, not SUBDIR.
Use TEMPLATE = subdirs instead of TEMPLATE = SUBDIRS, i.e. not upper case letters.
See the documentation for further details. You should have written this instead:
TEMPLATE = subdirs
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
SUBDIRS += \
MY_LIB \
MY_APP1
MY_LIB.file=/Users/username/MYLIB/mylib.pro
MY_APP1.file=/Users/username/MYAPP/App1/App1.pro

How to link a 3rd party library in linux for qml project

How do i link a 3rd party library in Qt Creator for a Qt Quick UI application.
I have library files built in linux(.so)
Thanks in advance
Your should create "Qt Quick Application *" project and .pro file should look like:
QT += core quick gui network
TEMPLATE = app
HEADERS += some .h files
SOURCES += some .cpp files
INCLUDEPATH += ../include
OTHER_FILES += *.qml #or path to qml files
LIBS += -lprotobuf # list of Libs, which you wish

Resources