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. Binding with Qt.locale()
Forum Updated to NodeBB v4.3 + New Features

Binding with Qt.locale()

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 198 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.
  • P Offline
    P Offline
    pi-null-mezon
    wrote on last edited by
    #1

    Should binding with Qt.locale() works?

    Example (2 states):

    Screenshot from 2020-08-13 13-22-42.png
    Screenshot from 2020-08-13 13-27-10.png

    Binding works with this declaration:

    import QtQuick 2.4
    import QtQuick.Controls 2.1
    import QtQuick.Window 2.1
    
    Window {
        id: window
        visible: true
        width: 320
        height: 240
    
        signal translationAsked(string language)
    
        Column {
            anchors.centerIn: parent
            spacing: 20
            Label {
                text: Qt.locale().name + " " +  Qt.locale().dateFormat(Locale.ShortFormat)
    
            }
            ComboBox {
                model: ["English","Русский"]
                onCurrentIndexChanged: translationAsked(model[currentIndex])
            }                
            Label {
                text: new Date().toLocaleDateString(Qt.locale(),Locale.ShortFormat)
            }
            Label {
                 text: any_not_defined_name // throws 'qrc:/main.qml:28: ReferenceError: fgh is not defined'
            }
        }
    }
    

    But stops to work if I comment last label (that causes ReferenceError). Does anybody know why? And how bind with Qt.locale() in right way?

    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