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

qsTr + arg and qsTr in model mixup

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 6.4.1
    • QML: Compiler
    • None

    Description

       

      There is some strangeness when using qsTr:

      import QtQuick
      
      Window {
          id: root
          width: 640
          height: 480
          visible: true
          title: qsTr("Title")
           
          property var columnModel: [
              {    
                  name: "Name",
              },   
              {    
                  name: qsTr("Name"),
              },
          ]
      
          property var columnModelToo: [
              {    
                  name: qsTr("Name"),
      
              },   
              {    
                  name: "Name",
      
              },
          ]
      
          Text {
              text: qsTr("Status: %1").arg("hungry")
          }
      }   
      

      First issue is that using it with arg leads to a:

      Error: main.qml:29:15: Could not compile binding for text: Cannot generate efficient code for call to untyped JavaScript function
              text: qsTr("Status: %1").arg("hungry")
                    ^^^^
      

      .

      Second issue is with lists for models, where the order of qsTr calls leads either to

      Error: main.qml:10:31: Could not compile binding for columnModel: Cannot generate efficient code for DefineObjectLiteral
          property var columnModel: [
                                    ^
      

      or to

      Error: main.qml:21:19: Could not compile binding for columnModelToo: Cannot generate efficient code for call to untyped JavaScript function
                  name: qsTr("Name"),
                        ^^^^
      

      .

      The first issue doesn't seem to pop up in dev.

       

      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
            cajus Cajus Pollmeier
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes