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

QML: alias attached objects and their properties

    XMLWordPrintable

Details

    • All

    Description

      Summary

      QML does not allow to alias attached objects or their properties.

      Description

      I don't see any technical restrictions as to why not support them. Attached properties are designed to be "on-demand" kind of things, but sometimes you may want them to always exist on an object, such as property alias actionId: textInput.EnterKeyAction.actionId from QtQuick.VirtualKeyboard module, maybe because your Enter key will always be customized on, like, each and every of three pages it will appear at.

      Steps to reproduce

      import QtQuick 2.15
      import QtQuick.Window 2.15
      
      Window {
          id: win
      
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          property alias ww1: Window
      // qrc:/main.qml:12:25: Invalid alias reference. Unable to find id "Window"
      
          property alias ww2: win.Window
      // qrc:/main.qml:15:25: Invalid alias target location: Window
      
          property alias ww3: Window.width
      // qrc:/main.qml:18:25: Invalid alias reference. Unable to find id "Window"
      
          property alias ww4: win.Window.width
      // qrc:/main.qml:21:25: Invalid alias target location: Window
      }
      

      Expected result

      All of those constructs should work, or at least ID-qualified ones.

      Actual result

      Compiler errors, as shows below each property line.

      Additional info complaints

      It would be nice if QML compiler could spit out everything it is unhappy with at once, instead of requiring me to uncomment each line and re-run the app to retrieve the next error. Besides, "Invalid alias reference" shouldn't really be such a blocker for the rest of processing, right?

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qtqmlteam Qt Qml Team User
            ratijas ivan tkachenko
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes