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

Make it possible to alias singleton objects

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.2.1
    • None
    • Ubuntu Linux 12.04 LTS, 64-bit
      Qt development environment installed from qt-opensource-linux-x64-5.2.1.run from qt-project.org
      3.9 GiB RAM, Intel i7-3740QM CPU

    Description

      Creating a property alias to a QML singleton object produces the following runtime error:

      Invalid alias reference. Unable to find id "AcmeSoftwareStyle"

      I attached a minimal project that shows the error. Commenting out the line causing the error will demonstrate that the singleton is implemented correctly.

      Here is the relevant QML:

      main.qml:JavaScript
      import QtQuick 2.0
      import "."
      
      Rectangle {
          width: 360
          height: 360
          color: AcmeSoftwareStyle.bkgdColor
      
          property alias style: AcmeSoftwareStyle  // <- comment out for app to work
      
          Text {
              text: qsTr("Hello World")
              color: AcmeSoftwareStyle.textColor
              font.pointSize: AcmeSoftwareStyle.font.pointSize.extraLarge
              anchors.centerIn: parent
              font.family: style.font.family       // should set font to courier
          }
      
          MouseArea { anchors.fill: parent; onClicked: Qt.quit() }
      }
      

      Attachments

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

        Activity

          People

            shausman Simon Hausmann
            stan.m Stanley Morris
            Votes:
            4 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes