Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt Creator doesn't see qml types in locally intalled qml molule
Forum Updated to NodeBB v4.3 + New Features

Qt Creator doesn't see qml types in locally intalled qml molule

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
5 Posts 2 Posters 2.2k 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.
  • K Offline
    K Offline
    kudroma
    wrote on last edited by
    #1

    I've created my project which consists of main.cpp, main.qml and module in some other local directory which I want to import.
    My application builds and works well.
    But Qt Creator doesn't see types from module and accentuates

    import MyModule 1.0

    in main.qml file with red line.

    How is it possible to make my module visible to Qt Creator?

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by A Former User
      #2

      Hi! Let's say your module is named "MyControls". And let's assume your application get's installed to
      install-root/bin/myapp.exe. You must then put your module in a sub-directory with the exact same name, here: install-root/bin/MyControls/. And you need the following files to be installed into that directory:

      MyControls.dll // compiled shared object part of the module
      SomeItem.qml 
      AnotherItem.qml
      qmldir // special file
      plugins.qmltypes // special file
      

      The qmldir file has to look like this:

      module MyControls
      plugin MyControls
      SomeItem 1.0 SomeItem.qml
      AnotherItem 1.0 AnotherItem.qml
      

      And the file plugins.qmltypes must be generated with qmlplugindump (see Generating qmltypes Files).

      And finally you need to tell Qt Creator where to find your module, by adding the directory to the QML module import path variable. With Qbs you can skip that last part and just add the following to your .qbs file:

          property string qmlImportPaths: "/blah/foo/bar/install-root/bin"
      

      And, yes, it's complicated ;-)

      1 Reply Last reply
      1
      • K Offline
        K Offline
        kudroma
        wrote on last edited by kudroma
        #3

        Great thank for your answer!

        Could you please explain what is plugin MyControls and MyControls.dll? Is it C++ plugin?
        And how to say Qt Creator about path where it is necessary to fing module? I included this path into INCLUDEPATH variable. But it didn't work.
        My application builds and works well. But when I edit code Qt Creator doesn't recognize types from module. Application runs well despite of it.

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          Could you please explain what is plugin MyControls and MyControls.dll? Is it C++ plugin?

          Yes, exactly. You can find in-depth info in Creating C++ Plugins for QML, and there is also an example: QML Plugin Example.

          And how to say Qt Creator about path (...) ?

          You need to add the path that contains your module-directory to the QML2_IMPORT_PATH environment variable. The easiest place to do that is in project settings > run environment:

          QML2_IMPORT_PATH = /blah/foo/bar/install-root/

          1 Reply Last reply
          1
          • K Offline
            K Offline
            kudroma
            wrote on last edited by kudroma
            #5

            Unfortunetely It doen't work.

            This is my project settings

            0_1490978725030_upload-2c6bb35f-e15c-4106-97f5-82c8565c1a67
            This is my main.qml
            0_1490978772590_upload-25731136-9755-48f8-a430-586c08fb85b7

            This is project directory:
            0_1490978815555_upload-3ee90741-06a5-43cd-8a72-e0ca8f3575fc

            This is MyModule directory:
            0_1490978975388_upload-e5f2119a-6a94-44ad-8f1d-e112f5233560

            And this is qmldir file:
            0_1490978888706_upload-4d3cbcb4-2699-4ca5-a6a7-9dd30125e3ac

            What is wrong?

            1 Reply Last reply
            0

            • Login

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