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

Can't read styleName property from font singleton

    XMLWordPrintable

Details

    • Windows
    • ce95fae56 (dev)

    Description

      I created a Singleton in which I declared a readonly font

      //Fonts.qml
      
      import QtQuick
      pragma Singleton
      
      Item {
          readonly property font primary: Qt.font({
              family: "DIN Next LT Pro",
              styleName: "Bold Condensed",
              pixelSize: 40
          })
      }
      

      and another qml file in which I am trying to read from this singleton.

      // Main.qml
      import QtQuick
      
      Window {
          id: window
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          Component.onCompleted: {
              console.log(Fonts.primary.family);
              console.log(Fonts.primary.styleName);
          }
      } 

      Running this code results in the following output:

      qml: DIN Next LT Pro
      qml:

      styleName also doesn't work if I am trying to use the font directly i.e. :

      Text {
          font: Fonts.primary
      }
      

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            steffenw Steffen Weyer
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes