Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML file from extension plugin -> "Unknown component"
Forum Updated to NodeBB v4.3 + New Features

QML file from extension plugin -> "Unknown component"

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 2 Posters 3.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bilouse
    wrote on 1 Sept 2014, 14:02 last edited by
    #1

    Hi all,

    I still manage to build properly a custom QML lib, so I built an extension plugin.

    Everything works fine except...code completion within QtCreator. But it works during execution.

    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.

    I tried many things...it never works.

    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 :
    @module customquick.controls
    GridMenu 1.0 GridMenu.qml
    plugin customquickcontrolsplugin
    classname CustomQuickControlsPlugin
    @

    main.qml
    @import QtQuick 2.2
    import QtQuick.Window 2.1
    import customquick.controls 1.0

    Window {
    visible: true
    width: 360
    height: 360

    GridMenu { *// <-- M300 error*
        id: menu
        anchors.fill: parent
    }
    

    }@

    GridMenu.qml
    @import QtQuick 2.0
    import customquick.controls 1.0

    Item {
    width: 100
    height: 80

    GridMenuLogic {
    
    }
    

    }
    @

    And my CustomQuickControlsPlugin class :
    @void CustomQuickControlsPlugin::registerTypes(const char *uri)
    {
    // @uri controls
    Q_ASSERT(uri == QLatin1String("customquick.controls"));
    qmlRegisterType<GridMenuLogic>(uri, 1, 0, "GridMenuLogic");
    }
    @

    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.

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leonardo.ramosantos
      wrote on 1 Sept 2014, 16:06 last edited by
      #2

      Hi,

      Did you try put this line in main.qml?
      #import GridMenuLogic 1.0

      []'s

      1 Reply Last reply
      0
      • B Offline
        B Offline
        Bilouse
        wrote on 1 Sept 2014, 16:26 last edited by
        #3

        Thanks for your reply.

        Yes, it doesn't work, the engine deosn't recognize it as a module.

        I tried to put GridMenu.qml in main.qml folder, and import with

        "import GridMenu.qml"

        but it failed too.

        1 Reply Last reply
        0
        • L Offline
          L Offline
          leonardo.ramosantos
          wrote on 1 Sept 2014, 17:25 last edited by
          #4

          Well,

          Try to put GridMenu folder's path in a "import" clause, like this:

          main.qml:
          #import "../libs/customquick/controls".

          []'s

          1 Reply Last reply
          0
          • B Offline
            B Offline
            Bilouse
            wrote on 1 Sept 2014, 17:42 last edited by
            #5

            Well well well... It works...partially :p

            Firstly, I got a...warning (in french) :
            "The QML module contains some C++ modules, reading type informations...".

            So, GridMenu is recognized by the code model, but if I run the program it doesn't work anymore :

            "QQmlApplicationEngine failed to load component
            qrc:///main.qml:5 "../libs/customquick/controls": no such directory"

            Maybe because main.qml is within a Qt resource file ?

            EDIT : ok...it's because the qrc file. If I copy main.qml in the build directory and I delete it from the resource file, It works. The "import" is still yellow underlined.

            1 Reply Last reply
            0

            1/5

            1 Sept 2014, 14:02

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved