Advertisement
mercibac

qmltranslator.py

May 25th, 2021
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. # This file is the equivalent of qmltranslor.h and qnltranslator.cpp mixed
  2. import sys
  3. import os
  4.  
  5. from PySide2.QtGui import QGuiApplication
  6. from PySide2.QtQml import QQmlApplicationEngine
  7. from PySide2.QtCore import Signal, Slot, QTranslator
  8. from main import *
  9.  
  10.  
  11. # QmlTranslator inherits App in order to access the function app.installTranslator
  12. # This class is exposed to the qml file
  13. class QmlTanslator(App):
  14.     def __init__(self, *args):
  15.        App.__init__(self)
  16.  
  17.        self.m_translator = QTranslator
  18.  
  19.     # signal emmited when language is changed
  20.     languageChanged =  Signal()
  21.  
  22.     #Slot responsible for the translation
  23.     @Slot(str)
  24.     def setTranslation(self, translation):
  25.         self.m_translator.load(translation)
  26.         app.installTranslator(self.m_translator)
  27.         self.languageChanged.emit()
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement