Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-84794

Selective import statements for QML

XMLWordPrintable

      A way to reduce the name clashes with multiple imports via a Python-like syntax:

      from QtQuick 2.0 import Rectangle, MouseArea
      
      Rectangle {}  // OK
      Item {} // NOT FOUND
      MouseArea {} // OK
      
      from QtQuick 2.0 as QQ2 import Rectangle
      
      Rectangle {} // NOT FOUND
      QQ2.Rectangle {} // OK
      QQ2.Item {} // NOT FOUND
      
      from QtQuick 2.0 import Rectangle as R, MouseArea as M
      
      Rectangle {} // NOT FOUND
      R {} // OK, alias for Rectangle
      

      And similar variations.

      The rationale is minimizing the clashes, just like in other languages.

      With the drop of versioned module imports in QML3, either one namespaces everything or we need something like this for long-term big-scale QML projects.

        For Gerrit Dashboard: QTBUG-84794
        # Subject Branch Project Status CR V

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            peppe Giuseppe D'Angelo
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                There is 1 open Gerrit change