Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to set or change QML Locale?
Forum Updated to NodeBB v4.3 + New Features

How to set or change QML Locale?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
5 Posts 3 Posters 5.5k 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.
  • N Offline
    N Offline
    NTMS
    wrote on last edited by
    #1

    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?

    Thanks

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

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

      1 Reply Last reply
      1
      • N Offline
        N Offline
        NTMS
        wrote on last edited by
        #3

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

        QLocale::setDefault(QLocale::Russian)

        @Wieland
        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.

        // RUSSIAN LANGUAGE LOGO
         Image {
             signal clicked()
             id: rusLogo
             anchors.top: parent.top
             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: {
                     rusLogo.clicked()
                     settings.language = "ru_RU"
                     NativeDialog.confirm("ru_RU Он был избран")
                 }
             }
         }
        
        T 1 Reply Last reply
        0
        • N NTMS

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

          QLocale::setDefault(QLocale::Russian)

          @Wieland
          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.

          // RUSSIAN LANGUAGE LOGO
           Image {
               signal clicked()
               id: rusLogo
               anchors.top: parent.top
               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: {
                       rusLogo.clicked()
                       settings.language = "ru_RU"
                       NativeDialog.confirm("ru_RU Он был избран")
                   }
               }
           }
          
          T Offline
          T Offline
          Tirupathi Korla
          wrote on last edited by Tirupathi Korla
          #4

          @NTMS
          Here is the link which shows how to interact between qml and cpp
          http://doc.qt.io/qt-5/qtqml-cppintegration-interactqmlfromcpp.html

          1 Reply Last reply
          0
          • N Offline
            N Offline
            NTMS
            wrote on last edited by
            #5

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

            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