How to embed qml-files etc. in executable file? [solved]
-
Hmm it seems to work but I'm running into a problem.
The compiler says:
@qrc:/qml/MyProject/main.qml:2:1: module ":.desktop-components.components" plugin "styleplugin" not found @This is qrc-file:
@<RCC>
<qresource prefix="/">
<file>qml/MyProject/main.qml</file>
<file>desktop-components/components/Button.qml</file>
<file>desktop-components/components/ButtonRow.qml</file>
<file>desktop-components/components/CheckBox.qml</file>
<file>desktop-components/components/ChoiceList.qml</file>
<file>desktop-components/components/components.pro</file>
<file>desktop-components/components/ContextMenu.qml</file>
<file>desktop-components/components/Dial.qml</file>
<file>desktop-components/components/Frame.qml</file>
<file>desktop-components/components/GroupBox.qml</file>
<file>desktop-components/components/HeaderSection.qml</file>
<file>desktop-components/components/Makefile</file>
<file>desktop-components/components/ProgressBar.qml</file>
<file>desktop-components/components/qmldir</file>
<file>desktop-components/components/RadioButton.qml</file>
<file>desktop-components/components/ScrollArea.qml</file>
<file>desktop-components/components/ScrollBar.qml</file>
<file>desktop-components/components/Slider.qml</file>
<file>desktop-components/components/SpinBox.qml</file>
<file>desktop-components/components/Switch.qml</file>
<file>desktop-components/components/Tab.qml</file>
<file>desktop-components/components/TabBar.qml</file>
<file>desktop-components/components/TabFrame.qml</file>
<file>desktop-components/components/TableView.qml</file>
<file>desktop-components/components/TextArea.qml</file>
<file>desktop-components/components/TextField.qml</file>
<file>desktop-components/components/ToolBar.qml</file>
<file>desktop-components/components/ToolButton.qml</file>
<file>desktop-components/components/plugin/libstyleplugin.a</file>
<file>desktop-components/components/plugin/styleplugin.dll</file>
</qresource>
</RCC>
@This is the start of main.qml
@import QtQuick 1.0
import "qrc:/desktop-components/components"
import "qrc:/desktop-components/components/plugin"@ -
Ah, you cannot compile a dll into the resource system. I do not think the library loader supports using the resource system. Also it doesn't really make sense to place a shared library inside the binary as it loses any benefit of being a shared library.
I think you'll need to remove your style plugin from the resource system and load that using the method I suggested above with QDeclarativeEngine::addImportPath().
-
Ah! I almost forget that libraries can't be resources.
It works now when styleplugin.dll is inside the .exe-folder.
I also placed a copy of styleplugin.dll inside the folder 'plugins' and added the following line in my main-function
@QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath() + "/plugins");@
but that doesn't work. What could be wrong here? applicationDirPath() returns the correct location.
-
OK, but that returns an error (I placed it in the main-function)
@QDeclarativeEngine::addImportPath(QCoreApplication::applicationDirPath() + "/plugins");@
@error: incomplete type 'QDeclarativeEngine' used in nested name specifier@
Adding it to the QmlApplicationViewer doesn't do anything
@ QmlApplicationViewer viewer;
viewer.addImportPath(QCoreApplication::applicationDirPath() + "/plugins");@Also the QtCreator-editor complains that it can't find both imports:
@import "qrc:/desktop-components/components"
import "qrc:/desktop-components/components/plugin"@ -
You set it solved but i can't see solution.. Could you write me solution?
-
Could you share code? thanks.
-
"look at cmake branch":https://github.com/nib952051/QtDesktopComponentsBackport/tree/cmake