Important: Please read the Qt Code of Conduct -

Translation inside ListElement

  • 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 :

             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 :

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

    Delegate :

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

    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


    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.

Log in to reply