No warning when importing directories with identically named types



  • If my directory structure is

    main.qml
    Controls/Button.qml
    ControlsEx/Button.qml

    and in main.qml I write

    @
    import "Controls"
    import "ControlsEx"
    @

    then ControlsEx/Button.qml silently overrides Controls/Button.qml. No warning, no sign that something goes wrong. Is it OK?


  • Moderators

    Agreed to the fact that no warning is shown, as an alternative you can import the Directories with a Qualifier as
    @
    import "Controls" as A
    import "ControlsEx" as B

    A.Rect {
    }
    
    B.Rect {
    }
    

    @

    will call the Rect's of corresponding QML files.



  • Sure I can use qualifiers.
    But to do this, I must know the problem exists. Other programmer can add new type (i.e. Button.qml), with identical name to some directory (i.e. DirectoryWithNewButton). It will break all the files like this one with no warnings

    @
    import "DirectoryWithOldButton"
    import "DirectoryWithNewButton"

    Button { ... } // error: will use type from DirectoryWithNewButton
    @


  • Moderators

    That would be a problem definitely. Maybe you can suggest this as a feature request to the Qt Creator developers.


Log in to reply
 

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