1

is it possible to set the translataable checkbox for everything inside the qtdesigner to disabled as default. I only need one language and much prefer the cleaner auto generated code, leaving the retranslateUI funtion empty and setting everything up in the constructor.

Setting the checkbox for everything to disabled is super annoying.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Jan
  • 88
  • 5

1 Answers1

0

Qt designer does not allow to do it, that is the default configuration that plugins have, so I will propose a workaround, modify the .ui with a small script to disable that property:

from PyQt4 import QtCore, QtXml

if __name__ == '__main__':

    filename = "/path/of/your_file.ui"

    file = QtCore.QFile(filename)
    if not file.open(QtCore.QFile.ReadOnly):
        sys.exit(-1)

    doc = QtXml.QDomDocument()
    if not doc.setContent(file):
        sys.exit(-1)
    file.close()

    strings = doc.elementsByTagName("string")
    for i in range(strings.count()):
        strings.item(i).toElement().setAttribute("notr", "true")

    if not file.open(QtCore.QFile.Truncate|QtCore.QFile.WriteOnly):
        sys.exit(-1)

    xml = doc.toByteArray()
    file.write(xml)
    file.close()

Note:

The script is compatible with PyQt4, PyQt5, PySide and PySide2, they should only change PyQt4 with the name of the other libraries.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241