Message Strings File



  • Hi,

    I have a lot of strings that describes a state. So it make sense to use lists. The following solution works (I use Text to have the chance to add more properties in the future like color, font, ...):

    @Text {
    id: text1
    text: txtList[1].text // normally 1 is a C++ property
    }

    property list<Text> txtList: [
    Text {text:"Hello0 "},
    Text {text:"Hello1 "},
    Text {text:"Hello2 "},
    Text {text:"Hello3 "}
    ]@

    The idea is to put all this message at his own file. But I found no solution for this. I create a QML file like this

    @import QtQuick 2.2

    QtObject
    {
    property list<Text> txtList: [
    Text {text:"Hello0 "},
    Text {text:"Hello1 "},
    Text {text:"Hello2 "},
    Text {text:"Hello3 "}
    ]
    }@

    And the usage of

    @MyStrings.txtList[1].text@

    end with a ReferenceError: MyStrings is not defined.

    Is there a simple solution?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.