How to import components from main folder to subfolder?



  • I have a qml file (DirectRegister.qml )in the same directory as main.qml and main.cpp but under QML folder in Qt creator. This folder is added when i added new qt quick file.When i use this( DirectRegister.qml) component in another files it is detecting but when i run the program it says .
    QQmlApplicationEngine failed to load component
    DirectRegister.qml is not a type.
    What's wrong am I doing? But this works fine when i add them to the resources.Is that the way to do?

    Problem: When i put qml files in different folders i import like this
    import "../subfolder".
    To import elements from main folder to subfolder i do like this
    import "./". Complied but again the same problem
    QQmlApplicationEngine failed to load component
    DirectRegister.qml is not a type.
    How to import components from main folder to subfolder?


  • Moderators

    @vishnu
    Try with a Qualifier as said here.
    Personally I always use Qt's resource system. In this way it is more easy to deploy.



  • @p3c0
    In order to organise files. I put in different folders. So now I want to import one file from sub folder to main folder and main folder to subfolder. In short can you please describe me?
    From subfolder to main folder : i do it like this
    import "../subfolder"

    But on reverse i am confused what to do.
    I read the document you described above but still I didn't get. I am sorry.


  • Moderators

    @vishnu

    From subfolder to main folder : i do it like this
    import "../subfolder"
    But on reverse i am confused what to do.

    How about import "../" ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.