Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Translation inside ListElement

    QML and Qt Quick
    1
    1
    134
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      DavidM29 last edited by DavidM29

      Hello,

      I'm handling a ListView with multiple options.
      This list view contains list element with different type of delegate (button, switch, textinput...)
      The only common thing among all those options is the optionName parameter. It is the text I want for the option.
      I want this name to be translate with the rest of my app. But I can't make it work.

      Here is what I tried :
      First attemp :

      Model :

           ListElement{
               type: "type1"
               optionName : qsTr("Parameter to be translated") + trans.emptyString  
                //Use the empty string because the Qt version I have is QT 5.6.3
           }
      

      With that I do have this error :

      ListElement: cannot use script for property value
      

      Second attemp :
      Model :

           ListElement{
               type: "type1"
               optionName : QT_TR_NOOP("Parameter to be translated")
           }
      

      Delegate :

      Component {
              id : usineDelegate
              BoutonOption{
                  id: type1Option
                  height: parent.height / 8
                  width: parent.width
                  nomOption: qsTr(optionName) + trans.emptyString //Here is what I tried
                  bouton.libelle: qsTr("Open")
                  bouton.press.onClicked: ouvrirParamUsine()
              }
          }
      

      Here I don't have any errors but the translation works everywhere exept on this.

      I also tried to make a property and load this property on

      Component.onCompleted
      

      But it tells me that my property is undefined even though I have just a qStr() + emptyString

      Does anybody see something I did wrong or have any other idea how to achieve this ? I don't know how to manage it.

      1 Reply Last reply Reply Quote 0
      • First post
        Last post