Important: Please read the Qt Code of Conduct -

How to set or change QML Locale?

  • Hi,

    In my QML app there are 2 different language settings. English or Russian. Translation is working. But for number format I need to change the current locale to English or Russian. How to set or change QML Locale?


  • Hi! You can set the locale via a call in your C++ backend: QLocale::setDefault(QLocale::Russian), see docs.

  • @Wieland said in How to set or change QML Locale?:


    Thank you very much. I have an image with has mouseArea as well as onClicked signal.
    So how dı I send the signal in C++ (QLocale::setDefault(QLocale::Russian)) to change the
    locale to Russian?

    I never use QML so I need to know how to send signal from QML to C++ and it will be very good to
    learn how to send signal from C++ to QML. Is it possible to just give me small example?

    Thank you.

     Image {
         signal clicked()
         id: rusLogo
         anchors.right: parent.right
         anchors.rightMargin: 0
         anchors.topMargin: 60
         fillMode: Image.PreserveAspectFit
         scale:  0.75
         source: "../../../assets/russianLogo.png"
         smooth: mouseAreaRus.containsMouse
         MouseArea {
             id: mouseAreaRus
             anchors.fill: rusLogo
             hoverEnabled: true         //this line will enable mouseArea.containsMouse
             onClicked: {
                 settings.language = "ru_RU"
                 NativeDialog.confirm("ru_RU Он был избран")

  • @NTMS
    Here is the link which shows how to interact between qml and cpp

  • @Tirupathi-Korla thanks. You save my day :)

Log in to reply