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?:
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 Он был избран") } } }
-
@NTMS
Here is the link which shows how to interact between qml and cpp
http://doc.qt.io/qt-5/qtqml-cppintegration-interactqmlfromcpp.html -
@Tirupathi-Korla thanks. You save my day :)