Advertisement
mercibac

main.qml

May 25th, 2021
1,986
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 2.39 KB | None | 0 0
  1.     import QtQuick 2.6
  2.     import QtQuick.Controls 1.5
  3.      
  4.     ApplicationWindow {
  5.         id: applicationWindow
  6.         visible: true
  7.         width: 640
  8.         height: 480
  9.      
  10.         Label {
  11.             id: helloLabel
  12.             height: 50
  13.             anchors {
  14.                 top: parent.top
  15.                 left: parent.left
  16.                 right: parent.horizontalCenter
  17.                 margins: 10
  18.             }
  19.         }
  20.      
  21.         ComboBox {
  22.             id: comboBox
  23.             anchors {
  24.                 top: parent.top
  25.                 left: parent.horizontalCenter
  26.                 right: parent.right
  27.                 margins: 10
  28.             }
  29.      
  30.             model: ["ru_RU", "en_US"]
  31.      
  32.             // If you change the text, initialize the translation unit via C++ Layer
  33.             onCurrentTextChanged: {
  34.                 qmlTranslator.setTranslation(comboBox.currentText)
  35.             }
  36.         }
  37.      
  38.         Label {
  39.             id: labelText
  40.             wrapMode: Text.Wrap
  41.             anchors {
  42.                 top: helloLabel.bottom
  43.                 left: parent.left
  44.                 right: parent.right
  45.                 margins: 10
  46.             }
  47.         }
  48.      
  49.         // Connect to an interpreter object
  50.         Connections {
  51.             target: qmlTranslator   // was registered in main.cpp
  52.             onLanguageChanged: {    // upon receipt of the signal to change the language
  53.                 retranslateUi()     // initialize interface translation
  54.             }
  55.         }
  56.      
  57.         // interface translation function
  58.         function retranslateUi() {
  59.             applicationWindow.title = qsTr("Hello World")
  60.             helloLabel.text = qsTr("Hello World")
  61.             labelText.text = qsTr("The QTranslator class provides internationalization" +
  62.                                   "support for text output.An object of this class contains " +
  63.                                   "a set of translations from a source language to a target language. " +
  64.                                   "QTranslator provides functions to look up translations in a translation file. " +
  65.                                   "Translation files are created using Qt Linguist.")
  66.         }
  67.        
  68.         // Start translating the application window when the application was created
  69.         Component.onCompleted: {
  70.             retranslateUi();
  71.         }
  72.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement