QML C++ extension, qml project can not find a type
I have this strange issue in my QML Project, that I have successfully created *.so file of my extension, which I have put in
Code:
/usr/lib/qt4/imports/Kornicameister/XMLWriterParser
along with qmldir file and at the very beginning after I've just added
Code:
import Kornicameister.XMLWriterParser 1.0
in QML file I am able to write
Code:
XMLWriterParser{
id: myItem
}
and everything works fine (I am also able to access methods declared in c++ code), but suddenly Creator fails to find imported plugin...this is pretty weird...even more if I could access myItem right after adding import statement
I am not quite sure which part of the code should I add, so I will post my repository github url https://github.com/kornicameister/QMLXMLParser
in this code I have two classes
- XMLParser
- XMLWriterParser
and I am trying to use XMLWriterParser inside QML system...
what I am doing wrong, that it fails to find my library correctly ? Maybe I am missing some headers, however documentation does not mention about headers at all...
additionally here is the pro file of the project where I am trying to use the plugin
Code:
# Add more folders to ship with the application, here
folder_01.source = qml/MajekTheGame
folder_01.target = qml
DEPLOYMENTFOLDERS = folder_01
# Additional import path used to resolve QML modules in Creator's code model
QML_IMPORT_PATH =
symbian:TARGET.UID3 = 0xE4C4158B
# Allow network access on Symbian
symbian:TARGET.CAPABILITY += NetworkServices
# Define QMLJSDEBUGGER to allow debugging of QML in debug builds
# (This might significantly increase build time)
# DEFINES += QMLJSDEBUGGER
# If your application uses the Qt Mobility libraries, uncomment
# the following lines and add the respective components to the
# MOBILITY variable.
# CONFIG += mobility
# MOBILITY +=
# The .cpp file which was generated for your project. Feel free to hack it.
SOURCES += main.cpp
# Please do not modify the following two lines. Required for deployment.
include(qmlapplicationviewer/qmlapplicationviewer.pri)
qtcAddDeployment()
OTHER_FILES +=
LIBS += -L/usr/lib/qt4/imports/KornicameisterQML/XMLWriterParser/ -lXMLParser
INCLUDEPATH += /usr/lib/qt4/imports/KornicameisterQML/XMLWriterParser/
DEPENDPATH += /usr/lib/qt4/imports/KornicameisterQML/XMLWriterParser/
Re: QML C++ extension, qml project can not find a type
Quote:
...but suddenly Creator fails to find imported plugin...
When? Inside of the QML-Designer? Or by starting your QML-Application?
1 Attachment(s)
Re: QML C++ extension, qml project can not find a type
Thanks for Your reply.
To be more specific, my type is not drawable... it more like a wrapper for XMLStreamWriter functionality.
QtCreator can't locate the package, I see the appropriate communicate inside Creator's code editor.
Attachment 6838
It looks like on the image I attached.
As i said before *.so file is located inside /usr/lib/imports directory
Code:
kornicameister@kornicameister:~$ ls -l /usr/lib/qt4/imports/KornicameisterQML/XMLParser/
razem 56
-rwxr-xr-x 1 root kornicameister 41840 09-12 08:37 libXMLWriter.so
-rw-r--r-- 1 root kornicameister 22 09-10 12:21 qmldir
-rw-r--r-- 1 root kornicameister 1631 09-10 12:20 xmlparser.h
-rw-r--r-- 1 root kornicameister 267 09-09 14:09 xmlparser_plugin.h
Added:
output from ldd for executable
Code:
kornicameister@kornicameister:~/Dropbox/Programming/Projects/QtQuick/MajekTheGame-build-desktop$ ldd MajekTheGame
linux-vdso.so.1 => (0x00007fff505ff000)
libXMLWriter.so => not found
libQtDeclarative.so.4 => /usr/lib/libQtDeclarative.so.4 (0x00007fe27532d000)
libQtGui.so.4 => /usr/lib/libQtGui.so.4 (0x00007fe27464c000)
libQtCore.so.4 => /usr/lib/libQtCore.so.4 (0x00007fe2741a6000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fe273f8a000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fe273c7f000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe2739fd000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fe2737e7000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe273462000)
libQtScript.so.4 => /usr/lib/libQtScript.so.4 (0x00007fe272fbd000)
libQtSql.so.4 => /usr/lib/libQtSql.so.4 (0x00007fe272d7b000)
libQtXmlPatterns.so.4 => /usr/lib/libQtXmlPatterns.so.4 (0x00007fe27272d000)
libQtNetwork.so.4 => /usr/lib/libQtNetwork.so.4 (0x00007fe2723ec000)
libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007fe2721b7000)
libaudio.so.2 => /usr/lib/x86_64-linux-gnu/libaudio.so.2 (0x00007fe271f9d000)
libglib-2.0.so.0 => /lib/libglib-2.0.so.0 (0x00007fe271cac000)
libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007fe271a86000)
libz.so.1 => /usr/lib/libz.so.1 (0x00007fe27186e000)
libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007fe2715d1000)
libgobject-2.0.so.0 => /usr/lib/libgobject-2.0.so.0 (0x00007fe27137f000)
libSM.so.6 => /usr/lib/x86_64-linux-gnu/libSM.so.6 (0x00007fe271177000)
libICE.so.6 => /usr/lib/x86_64-linux-gnu/libICE.so.6 (0x00007fe270f5c000)
libXrender.so.1 => /usr/lib/x86_64-linux-gnu/libXrender.so.1 (0x00007fe270d52000)
libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007fe270b3e000)
libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007fe2707ff000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fe2705fb000)
libgthread-2.0.so.0 => /usr/lib/libgthread-2.0.so.0 (0x00007fe2703f6000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fe2701ee000)
/lib64/ld-linux-x86-64.so.2 (0x00007fe2758ac000)
libexpat.so.1 => /usr/lib/libexpat.so.1 (0x00007fe26ffc5000)
libXt.so.6 => /usr/lib/x86_64-linux-gnu/libXt.so.6 (0x00007fe26fd60000)
libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007fe26fb5d000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fe26f920000)
libuuid.so.1 => /lib/libuuid.so.1 (0x00007fe26f71c000)
libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007fe26f4ff000)
libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007fe26f2fa000)
ldd reports failure in locating my library file as well
I do not what I did wrong, but I've tried to follow the tutorial as it goes...
I thought that maybe missing headers were the problem, but as You can see, I placed them inside lib directory in /usr/lib/qt4/imports/
I have even added the library via QtCreator, check my first post, linker locates the library correctly, in other words I do not see linker error of not locating library
it helped me more than nothing
Re: QML C++ extension, qml project can not find a type
Isn't it an issue with your package and Qt Creator being built using different compilers?
Re: QML C++ extension, qml project can not find a type
1.
Quote:
ldd reports failure in locating my library file as well
...Plugin is loaded dynamically, because of this the linker will not find it.
You have placed your plugin in the default "Import-Path". Perhaps it is not necessary to set the Plugin-Path inside your application. If your application starts, it will be ok, otherwise I would add the PluginPath, like this:
Code:
QDeclarativeEngine::addPluginPath
Perhaps in your case:
Code:
viewer.engine()->addPluginPath()
2.
Quote:
QtCreator can't locate the package, ....It looks like on the image I attached.
I think, you can use your Plugin, you can use your classes, but QtCreator does not know them. Because of this they are underlined.
a.) Look at your qmldir-file. It should mean:
"plugin XMLWriter 1.0"
b.) The following was written inside of the QtCreator-Doc:
Quote:
Ideally, QML modules have a plugins.qmltypes file in the same directory as the qmldir file. The qmltypes file contains a description of the components exported by the module's plugins and is loaded by Qt Creator when the module is imported.
What i have done:
1.) I compiled the prog in qtcreator-2.3.0\share\qtcreator\qml\qmldump
2.) I called .\release\qmldump by the follwing arguments - perhaps in your case:
Code:
./qmldump KornicameisterQML.XMLParser 1.0 /usr/lib/qt4/imports > /usr/lib/qt4/imports/KornicameisterQML/XMLParser/plugins.qmltypes
3.) Important: the file has to be known as "plugins.qmltypes". If you take another name, it will fail. If you know why, post it :)
4.) Important: After this, if you will design an element inside of the QMLDesigner, QtCreator will always say "Package not found". This is, because he uses his own "Import-Path" located in "qtcreator-2.3.0\bin\". Place a "qt.conf" in qtcreator-2.3.0\bin with the following lines:
Code:
[Paths]
Imports = /usr/lib/qt4/imports
Perhaps this will help...
Good luck:)
Added after 11 minutes:
@wysota
Quote:
Isn't it an issue with your package and Qt Creator being built using different compilers?
I think this occures only under Windows with msvc2008, mingw and if you create a Style-Plugin for integrating your components in QMLDesigner, like "customstyleplugin" and "Qt.labs.components.custom". Isn't it?
Re: QML C++ extension, qml project can not find a type
I managed to solve the problem, now I am able to recognize the type I create inside of the QtCreator (syntax) and build projects which uses "my type"
thanks for the tips
@SamFredericks
Your tips with qmldump were vital for problem solution, thanks for them
@wysota
I think that the issue with compilers is as SamFredericks suggested, because I can build my project, which uses the plugin without any compiler build-time errors