Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Message Strings File
Qt 6.11 is out! See what's new in the release blog

Message Strings File

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 576 Views 1 Watching
  • 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.
  • K Offline
    K Offline
    kortus
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved