Results 1 to 6 of 6

Thread: QML C++ extension, qml project can not find a type

  1. #1
    Join Date
    Sep 2010
    Location
    Poland
    Posts
    112
    Thanks
    8
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default 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
    Qt Code:
    1. /usr/lib/qt4/imports/Kornicameister/XMLWriterParser
    To copy to clipboard, switch view to plain text mode 
    along with qmldir file and at the very beginning after I've just added
    Qt Code:
    1. import Kornicameister.XMLWriterParser 1.0
    To copy to clipboard, switch view to plain text mode 
    in QML file I am able to write
    Qt Code:
    1. XMLWriterParser{
    2. id: myItem
    3. }
    To copy to clipboard, switch view to plain text mode 
    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
    Qt Code:
    1. # Add more folders to ship with the application, here
    2. folder_01.source = qml/MajekTheGame
    3. folder_01.target = qml
    4. DEPLOYMENTFOLDERS = folder_01
    5.  
    6. # Additional import path used to resolve QML modules in Creator's code model
    7. QML_IMPORT_PATH =
    8.  
    9. symbian:TARGET.UID3 = 0xE4C4158B
    10.  
    11. # Allow network access on Symbian
    12. symbian:TARGET.CAPABILITY += NetworkServices
    13.  
    14. # Define QMLJSDEBUGGER to allow debugging of QML in debug builds
    15. # (This might significantly increase build time)
    16. # DEFINES += QMLJSDEBUGGER
    17.  
    18. # If your application uses the Qt Mobility libraries, uncomment
    19. # the following lines and add the respective components to the
    20. # MOBILITY variable.
    21. # CONFIG += mobility
    22. # MOBILITY +=
    23.  
    24. # The .cpp file which was generated for your project. Feel free to hack it.
    25. SOURCES += main.cpp
    26.  
    27. # Please do not modify the following two lines. Required for deployment.
    28. include(qmlapplicationviewer/qmlapplicationviewer.pri)
    29. qtcAddDeployment()
    30.  
    31. OTHER_FILES +=
    32.  
    33. LIBS += -L/usr/lib/qt4/imports/KornicameisterQML/XMLWriterParser/ -lXMLParser
    34. INCLUDEPATH += /usr/lib/qt4/imports/KornicameisterQML/XMLWriterParser/
    35. DEPENDPATH += /usr/lib/qt4/imports/KornicameisterQML/XMLWriterParser/
    To copy to clipboard, switch view to plain text mode 
    My schedule makes my cry
    My works makes my laugh
    My life makes... oh...no....

  2. #2
    Join Date
    May 2011
    Posts
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QML C++ extension, qml project can not find a type

    ...but suddenly Creator fails to find imported plugin...
    When? Inside of the QML-Designer? Or by starting your QML-Application?

  3. #3
    Join Date
    Sep 2010
    Location
    Poland
    Posts
    112
    Thanks
    8
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default 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.
    error.jpg
    It looks like on the image I attached.

    As i said before *.so file is located inside /usr/lib/imports directory
    Qt Code:
    1. kornicameister@kornicameister:~$ ls -l /usr/lib/qt4/imports/KornicameisterQML/XMLParser/
    2. razem 56
    3. -rwxr-xr-x 1 root kornicameister 41840 09-12 08:37 libXMLWriter.so
    4. -rw-r--r-- 1 root kornicameister 22 09-10 12:21 qmldir
    5. -rw-r--r-- 1 root kornicameister 1631 09-10 12:20 xmlparser.h
    6. -rw-r--r-- 1 root kornicameister 267 09-09 14:09 xmlparser_plugin.h
    To copy to clipboard, switch view to plain text mode 

    Added:
    output from ldd for executable
    Qt Code:
    1. kornicameister@kornicameister:~/Dropbox/Programming/Projects/QtQuick/MajekTheGame-build-desktop$ ldd MajekTheGame
    2. linux-vdso.so.1 => (0x00007fff505ff000)
    3. libXMLWriter.so => not found
    4. libQtDeclarative.so.4 => /usr/lib/libQtDeclarative.so.4 (0x00007fe27532d000)
    5. libQtGui.so.4 => /usr/lib/libQtGui.so.4 (0x00007fe27464c000)
    6. libQtCore.so.4 => /usr/lib/libQtCore.so.4 (0x00007fe2741a6000)
    7. libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fe273f8a000)
    8. libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fe273c7f000)
    9. libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe2739fd000)
    10. libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fe2737e7000)
    11. libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe273462000)
    12. libQtScript.so.4 => /usr/lib/libQtScript.so.4 (0x00007fe272fbd000)
    13. libQtSql.so.4 => /usr/lib/libQtSql.so.4 (0x00007fe272d7b000)
    14. libQtXmlPatterns.so.4 => /usr/lib/libQtXmlPatterns.so.4 (0x00007fe27272d000)
    15. libQtNetwork.so.4 => /usr/lib/libQtNetwork.so.4 (0x00007fe2723ec000)
    16. libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007fe2721b7000)
    17. libaudio.so.2 => /usr/lib/x86_64-linux-gnu/libaudio.so.2 (0x00007fe271f9d000)
    18. libglib-2.0.so.0 => /lib/libglib-2.0.so.0 (0x00007fe271cac000)
    19. libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007fe271a86000)
    20. libz.so.1 => /usr/lib/libz.so.1 (0x00007fe27186e000)
    21. libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007fe2715d1000)
    22. libgobject-2.0.so.0 => /usr/lib/libgobject-2.0.so.0 (0x00007fe27137f000)
    23. libSM.so.6 => /usr/lib/x86_64-linux-gnu/libSM.so.6 (0x00007fe271177000)
    24. libICE.so.6 => /usr/lib/x86_64-linux-gnu/libICE.so.6 (0x00007fe270f5c000)
    25. libXrender.so.1 => /usr/lib/x86_64-linux-gnu/libXrender.so.1 (0x00007fe270d52000)
    26. libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007fe270b3e000)
    27. libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007fe2707ff000)
    28. libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fe2705fb000)
    29. libgthread-2.0.so.0 => /usr/lib/libgthread-2.0.so.0 (0x00007fe2703f6000)
    30. librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fe2701ee000)
    31. /lib64/ld-linux-x86-64.so.2 (0x00007fe2758ac000)
    32. libexpat.so.1 => /usr/lib/libexpat.so.1 (0x00007fe26ffc5000)
    33. libXt.so.6 => /usr/lib/x86_64-linux-gnu/libXt.so.6 (0x00007fe26fd60000)
    34. libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007fe26fb5d000)
    35. libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fe26f920000)
    36. libuuid.so.1 => /lib/libuuid.so.1 (0x00007fe26f71c000)
    37. libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007fe26f4ff000)
    38. libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007fe26f2fa000)
    To copy to clipboard, switch view to plain text mode 
    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
    Last edited by kornicameister; 12th September 2011 at 08:26. Reason: added ldd output
    My schedule makes my cry
    My works makes my laugh
    My life makes... oh...no....

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default 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?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    May 2011
    Posts
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QML C++ extension, qml project can not find a type

    1.
    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:

    Qt Code:
    1. QDeclarativeEngine::addPluginPath
    To copy to clipboard, switch view to plain text mode 
    Perhaps in your case:
    Qt Code:
    1. viewer.engine()->addPluginPath()
    To copy to clipboard, switch view to plain text mode 


    2.
    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:
    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:
    Qt Code:
    1. ./qmldump KornicameisterQML.XMLParser 1.0 /usr/lib/qt4/imports > /usr/lib/qt4/imports/KornicameisterQML/XMLParser/plugins.qmltypes
    To copy to clipboard, switch view to plain text mode 
    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:
    Qt Code:
    1. [Paths]
    2. Imports = /usr/lib/qt4/imports
    To copy to clipboard, switch view to plain text mode 


    Perhaps this will help...
    Good luck


    Added after 11 minutes:


    @wysota
    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?
    Last edited by SamFredericks; 12th September 2011 at 09:50.

  6. The following user says thank you to SamFredericks for this useful post:

    kornicameister (18th September 2011)

  7. #6
    Join Date
    Sep 2010
    Location
    Poland
    Posts
    112
    Thanks
    8
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default 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
    My schedule makes my cry
    My works makes my laugh
    My life makes... oh...no....

Similar Threads

  1. How to Find the Bus Type in QT? Using STORAGE_ADAPTER_DESCRIPTOR???
    By Gokulnathvc in forum General Programming
    Replies: 19
    Last Post: 7th April 2011, 11:18
  2. Replies: 0
    Last Post: 17th December 2010, 08:50
  3. using qmotif extension
    By pascasio in forum Newbie
    Replies: 7
    Last Post: 30th November 2010, 13:53
  4. Using Qt with kernel extension dll
    By ramazangirgin in forum Qt Programming
    Replies: 1
    Last Post: 21st January 2008, 13:23
  5. Replies: 17
    Last Post: 31st March 2006, 05:57

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.