Contents

How To Create Separated Components Directories And Access With Versions

   Jul 8, 2023     1 min read

Hi I writing this document because in the past i wanted to create many components without use C++, And setting up version for up them

maybe you ask why?
Just see your projects
You trying create many custom components for your projects first of everything it’s fine because they are not very much
Nut after months or week you seeing oh they are very much and It’s very confused,

Until this everything it’s ok
you again try for continue but again you trying create new components with many new feature
Maybe you saying it’s ok
Maybe you saying it’s ok i must just create new directory
Or i must just use git
But they aren’t best way you need create version for access them.

ok now let's go

How to create QMLDir file

  1. create a directory for your components (it’s not matter you use Qt creator or terminal linux or….) after that going into directory:
    • create file qmldir (example i use terminal in Gnu\Linux)
    • touch qmldir
  2. open it and
    • example i use directory with name DesingControls
    • module DesingControls (name attention you must Observe the big or small letters )
  3. open now open .pro file (because i use qmake alternative cmake)
    • QML_IMPORT_PATH += $$PWD/src/Ui (example i create a directory src and into i create directory Ui for qml files)
  4. adding path components directory into main.cpp
    • engine.addImportPath("qrc:/src/Ui"); (engin is a object of QQmlApplicationEngine)
  5. now thinking you must add version for specific custom components
    • CustomButton 1.0 CustomButton.qml


and now oh how can must use it
imaging it’s so hard 😂

let’s go to file qml and just add this

example:

  • import DesingControls 1.0

in feature i trying write a example project for it

thank you for reading this post
I wish you have great time