Skip to content
  • 0 Votes
    13 Posts
    2k Views
    C
    @KroMignon Hey! I forgot to answer to you! Did not meant to be rude and sorry for that :( Conclusion: I gave some tries with your suggest and lots of other stuff on internet, but failed :D So I have created a "Restart the system to apply all the language changes" screen and a "restart/cancel" choice on a language change state. I guess it will be okay even if it wont be "real-time" :P Good Work!
  • 0 Votes
    3 Posts
    798 Views
    C
    @KroMignon LOVE YOU! Thank you very much, worked w/out problems, and made me understand my mistake. note: Needed to update .ts file and release .qm file after changing code.
  • 0 Votes
    1 Posts
    462 Views
    No one has replied
  • How to access an ID across QML files

    Unsolved QML and Qt Quick qml qtquick qtquick 1.0 qtquick2
    11
    0 Votes
    11 Posts
    16k Views
    timdayT
    This got me thinking about how I structure things, which generally results from starting with a small one-file prototype and then breaking bits of it off into different files. Here's an example (all these can be run with qmlscene main.qml): First you might have File main.qml // main.qml import QtQuick 2.7 Rectangle { id: main width: 640 height: 480 property string msg0: "Some text" property string msg1: "Some more text" Column { anchors.centerIn: parent Text {text: main.msg0} Text {text: main.msg1} } } then you might try and organize stuff a bit: import QtQuick 2.7 Rectangle { id: main width: 640 height: 480 Item { id: config property string msg0: "Some text" property string msg1: "Some more text" } Column { anchors.centerIn: parent Text {text: config.msg0} Text {text: config.msg1} } } then you might split that up with a Config.qml: import QtQuick 2.7 Item { property string msg0: "Some text" property string msg1: "Some more text" } and main.qml now simplified to: import QtQuick 2.7 Rectangle { id: main width: 640 height: 480 Config {id: config} Column { anchors.centerIn: parent Text {text: config.msg0} Text {text: config.msg1} } } and then you start moving out other bits of functionality e.g adding a Messages.qml: import QtQuick 2.7 Column { anchors.centerIn: parent Text {text: config.msg0} Text {text: config.msg1} } and main.qml now simplified to: import QtQuick 2.7 Rectangle { id: main width: 640 height: 480 Config {id: config} Messages {} } I've never felt any need for singletons in QML code at all. (Having the hosting C++ set some context properties based on environment or command-line-options is the probably the closest I've come).
  • 0 Votes
    25 Posts
    13k Views
    p3c0P
    @Chillax You're Welcome :)