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. How to create a quick plugin with a dot "." in the "URI"
Forum Updated to NodeBB v4.3 + New Features

How to create a quick plugin with a dot "." in the "URI"

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 275 Views
  • 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.
  • S Offline
    S Offline
    Sauntor
    wrote on last edited by Sauntor
    #1

    After you create a Qt Quick 2 Extension plugin in qtcreator with cmake as the build system (let the project name to be MyDemo and check the Create example project checkbox ),
    Then, you will get something like this in the CMakeLists.txt:

    qt_add_library(MyDemo STATIC)
    qt_add_qml_module(MyDemo
        URI MyDemo
        VERSION 1.0
        QML_FILES MyItemControls.qml
        SOURCES myitem.cpp myitem.h
    )
    

    After that, if you change the URI MyDemo to URI My.Demo, the exmaple subproject can not be compiled successfully.

    no matter changing the qmldir file in the project root or not, the example project can not be compiled

    So, how to define a Quick extension plugin with an URI which contains a dot like My.Module.UI?

    A 1 Reply Last reply
    0
    • S Sauntor

      After you create a Qt Quick 2 Extension plugin in qtcreator with cmake as the build system (let the project name to be MyDemo and check the Create example project checkbox ),
      Then, you will get something like this in the CMakeLists.txt:

      qt_add_library(MyDemo STATIC)
      qt_add_qml_module(MyDemo
          URI MyDemo
          VERSION 1.0
          QML_FILES MyItemControls.qml
          SOURCES myitem.cpp myitem.h
      )
      

      After that, if you change the URI MyDemo to URI My.Demo, the exmaple subproject can not be compiled successfully.

      no matter changing the qmldir file in the project root or not, the example project can not be compiled

      So, how to define a Quick extension plugin with an URI which contains a dot like My.Module.UI?

      A Offline
      A Offline
      Anumas
      wrote on last edited by Anumas
      #2

      @Sauntor You use the dot notation to reflect your project structure. If you have the following project structure: MyDemo/InnerMyDemo. In the CMakeLists.txt inside you InnerMyDemo dir you can have:

      add_library(InnerMyDemoLib)
      qt_add_qml_module(InnerMyDemoLib
          URI MyDemo.InnerMyDemoLib
           ....
      )
      

      Look at: https://doc.qt.io/qt-6/cmake-build-reusable-qml-module.html, https://doc.qt.io/qt-6/qtqml-writing-a-module.html

      Note: If you don't want to reflect your project structure there's some CMake variable to define your custom layout. Look at: https://doc.qt.io/qt-6/qtqml-writing-a-module.html#custom-directory-layouts

      Say hello to a bright day.-

      Anumas.

      S 1 Reply Last reply
      0
      • A Anumas

        @Sauntor You use the dot notation to reflect your project structure. If you have the following project structure: MyDemo/InnerMyDemo. In the CMakeLists.txt inside you InnerMyDemo dir you can have:

        add_library(InnerMyDemoLib)
        qt_add_qml_module(InnerMyDemoLib
            URI MyDemo.InnerMyDemoLib
             ....
        )
        

        Look at: https://doc.qt.io/qt-6/cmake-build-reusable-qml-module.html, https://doc.qt.io/qt-6/qtqml-writing-a-module.html

        Note: If you don't want to reflect your project structure there's some CMake variable to define your custom layout. Look at: https://doc.qt.io/qt-6/qtqml-writing-a-module.html#custom-directory-layouts

        S Offline
        S Offline
        Sauntor
        wrote on last edited by
        #3

        @Anumas Thanks, I find out the really problem I got before, URI will composed with QT_QML_OUTPUT_DIRECTORY and the OUPUT_DIRECTORY parameter of qt_add_qml_module() to making some directories or target filename while building, and that cause conflicts

        1 Reply Last reply
        0
        • S Sauntor has marked this topic as solved on
        • S Sauntor has marked this topic as solved on

        • Login

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