Results 1 to 2 of 2

Thread: QML file from extension plugin -> "Unknown component"

  1. #1

    Default QML file from extension plugin -> "Unknown component"

    Hi all,

    I built an QML extension plugin for reusability.

    I linked it to my app project. No problem during execution. Everything works fine except...code completion within QtCreator : my custom QML type (defined in a QML file, not a QML binding from C++) isn't recognized by the QML editor. It's very frustrating.

    Here's my project's structure :

    src
    -- app
    ---- some things
    ---- qml.qrc
    ------ main.qml // error M300
    -- libs
    ---- customquick // Folder of QML plugins
    ------ controls // my extension plugin
    -------- customquickcontrolsplugin.(h/cpp)
    -------- gridmenulogic.(h/cpp) // C++ binding class
    -------- GridMenu.qml // the type which isn't recognized in main.qml
    -------- qmldir

    My qmldir :
    Qt Code:
    1. module customquick.controls
    2. GridMenu 1.0 GridMenu.qml
    3. plugin customquickcontrolsplugin
    4. classname CustomQuickControlsPlugin
    To copy to clipboard, switch view to plain text mode 


    main.qml
    Qt Code:
    1. import QtQuick 2.2
    2. import QtQuick.Window 2.1
    3. import customquick.controls 1.0
    4.  
    5. Window {
    6. visible: true
    7. width: 360
    8. height: 360
    9.  
    10. GridMenu { // <-- M300 error
    11. id: menu
    12. anchors.fill: parent
    13. }
    14. }
    To copy to clipboard, switch view to plain text mode 

    GridMenu.qml
    Qt Code:
    1. import QtQuick 2.0
    2. import customquick.controls 1.0
    3.  
    4. Item {
    5. width: 100
    6. height: 80
    7.  
    8. GridMenuLogic {
    9.  
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 

    And my CustomQuickControlsPlugin class :
    Qt Code:
    1. void CustomQuickControlsPlugin::registerTypes(const char *uri)
    2. {
    3. // @uri controls
    4. Q_ASSERT(uri == QLatin1String("customquick.controls"));
    5. qmlRegisterType<GridMenuLogic>(uri, 1, 0, "GridMenuLogic");
    6. }
    To copy to clipboard, switch view to plain text mode 

    The project copies the .qml files to the build directory and I setted the "QML2_IMPORT_PATH" environment var. But GridMenu is still underlined in main.qml...

    I works with QtCreator 3.2.0 and Ubuntu 14.04.

    Thanks for your help.

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

    Default Re: QML file from extension plugin -> "Unknown component"

    You need to provide a "qmltypes" file for your module. Have a look at "Module Definition qmldir Files" entry in the docs for further reference.
    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.


Similar Threads

  1. Replies: 2
    Last Post: 10th August 2012, 19:41
  2. Replies: 3
    Last Post: 15th February 2010, 17:27
  3. xlib: extension "XFree86-DRI" missing on display ":0.0".
    By kiransu123 in forum Qt Programming
    Replies: 5
    Last Post: 3rd August 2009, 14:43
  4. Replies: 0
    Last Post: 3rd December 2008, 11:58
  5. Replies: 3
    Last Post: 8th July 2008, 19:37

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.