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. No warning when importing directories with identically named types
Forum Updated to NodeBB v4.3 + New Features

No warning when importing directories with identically named types

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 961 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.
  • Q Offline
    Q Offline
    QtYury
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      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.

      157

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        QtYury
        wrote on last edited by
        #3

        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
        @

        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

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

          157

          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