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

[Reg 6.2 -> 6.3] qsTr with %n can cause error "Unable to assign [undefined] to QString" if qml added with qt_add_qml_module

    XMLWordPrintable

    Details

    • Commits:
      6efb9946cf43a369e71fa182da97d7510d86579f

      Description

      The following QML results in error "qrc:/msg/main.qml:23:13: Unable to assign [undefined] to QString" if added with qt_add_qml_module:

      import QtQuick
      import QtQuick.Controls
      import msg
      
      Window {
          id: win
          width: 640
          height: 480
          visible: true
          title: qsTr('Hello world')
      
          readonly property int count: 50
      
          Column {
              anchors.fill: parent
      
              Label {
                  text: qsTr('%1 message(s)', 'dashboard').arg(win.count)
                  height: 50
              }
      
              Label { //This does not work
                  text: qsTr('%n message(s)', 'dashboard', win.count)
                  height: 50
              }
      
              Label {
                  text: qsTr('%n message(s)', 'dashboard', 50)
                  height: 50
              }
      
              Label {
                  text: qsTr('%n message(s)', 'dashboard', Message.count)
                  height: 50
              }
          }
      }
      
      

      If the qml file above is added manually via qrc (qt_add_executable) and loaded the problem does not occur. Can be tested with "-w" command line arg in the test project.

      Steps to reproduce the problem:

      1. run the attached project => error occurs
      2. run the attached project with "-w" => no error

      The same problem cannot be reproduced with Qt 6.2.3 at all.

        Attachments

          Issue Links

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

            Activity

              People

              Assignee:
              ulherman Ulf Hermann
              Reporter:
              miikapernu Miika Pernu
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes