How to import c++ qml plugin to python project?
-
I've written a c++/qml plugin and now I want to integrate it to my python project. However, even I set correct .dll path for
QPluginLoader
, the errorString()` still shows:The plugin 'C:/Users/ASUS/Documents/Qt Project/cv-tools/3rdparty/KmcUI/bin/KmcUI/KmcUI.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)
What's more, all
.qrc
references in the library qml file seem to be invalid, so files referenced in qrc format cannot be used. How to solve my problems? -
I've written a c++/qml plugin and now I want to integrate it to my python project. However, even I set correct .dll path for
QPluginLoader
, the errorString()` still shows:The plugin 'C:/Users/ASUS/Documents/Qt Project/cv-tools/3rdparty/KmcUI/bin/KmcUI/KmcUI.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)
What's more, all
.qrc
references in the library qml file seem to be invalid, so files referenced in qrc format cannot be used. How to solve my problems?@Kamichanw said in How to import c++ qml plugin to python project?:
uses incompatible Qt library. (Cannot mix debug and release libraries.)
So between this third-party library and your own code (or whatever the Python uses from Qt libraries) is one compiled for debug and the other for release?
-
@Kamichanw said in How to import c++ qml plugin to python project?:
uses incompatible Qt library. (Cannot mix debug and release libraries.)
So between this third-party library and your own code (or whatever the Python uses from Qt libraries) is one compiled for debug and the other for release?
-
@JonB No. Actually, I just used debug mode to complie my library and load it in python project. In addition, I also compiled a release version, but it could not be loaded.
@Kamichanw
You show(Cannot mix debug and release libraries.)
What would you like people to say about this situation?
-
@Kamichanw
You show(Cannot mix debug and release libraries.)
What would you like people to say about this situation?
@JonB Fine... I just want to figure out how to build c++ plugin properly and apply it to python project. Here is how I build and use my dll
- Open libray .pro file and click Build in debug mode.
- Use QPluginLoader as follows
loader = QPluginLoader() loader.setFileName(str(KMCUI_PATH / "bin/kmcuiplugin.dll")) loader.load()
Here is content of my library .pro file:
TEMPLATE = lib QT += qml quick CONFIG += plugin qmltypes TARGET = $$qtLibraryTarget(kmcuiplugin) QML_IMPORT_NAME = KmcUI QML_IMPORT_VERSION = 1.0 RESOURCES += ... HEADERS += ... SOURCES += ... DESTDIR = $$PWD/bin DISTFILES += ... CONFIG += install_ok
-
@JonB Fine... I just want to figure out how to build c++ plugin properly and apply it to python project. Here is how I build and use my dll
- Open libray .pro file and click Build in debug mode.
- Use QPluginLoader as follows
loader = QPluginLoader() loader.setFileName(str(KMCUI_PATH / "bin/kmcuiplugin.dll")) loader.load()
Here is content of my library .pro file:
TEMPLATE = lib QT += qml quick CONFIG += plugin qmltypes TARGET = $$qtLibraryTarget(kmcuiplugin) QML_IMPORT_NAME = KmcUI QML_IMPORT_VERSION = 1.0 RESOURCES += ... HEADERS += ... SOURCES += ... DESTDIR = $$PWD/bin DISTFILES += ... CONFIG += install_ok
@Kamichanw said in How to import c++ qml plugin to python project?:
Open libray .pro file and click Build in debug mode.
So have you tried building in Release mode instead and see whether the message is affected?
-
@Kamichanw said in How to import c++ qml plugin to python project?:
Open libray .pro file and click Build in debug mode.
So have you tried building in Release mode instead and see whether the message is affected?
-
I tried to load this plugin by
QQmlApplicationEngine::addPluginPath
, which is the way I load successfully in C++. But it still showsUnable to load library C:\Users\ASUS\Documents\Qt Project\cv-tools\3rdparty\KmcUI\bin\kmcuiplugin.dll: The specified program could not be found.
But I'm pretty sure there exists such a dll.