Skip to content

QtWidgets.QApplication.translate syntax error using PySide #129

@elveatles

Description

@elveatles

The translate method is different between Qt4 and Qt5.
You can try this Python code:

import sys

from Qt import QtWidgets

class MainWindow(QtWidgets.QWidget):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        title = QtWidgets.QApplication.translate("MainWindow", "MainWindow", None, -1)

def main():
    app = QtWidgets.QApplication(sys.argv)
    mainWindow = MainWindow()
    mainWindow.show()
    app.exec_()

if __name__ == '__main__':
    main()

If I have PySide2, this will work. If I have PySide, I will get the error:

TypeError: 'PySide.QtCore.QCoreApplication.translate' called with wrong argument types:
PySide.QtCore.QCoreApplication.translate(str, str, NoneType, int)
Supported signatures:
PySide.QtCore.QCoreApplication.translate(str, str, str = None, PySide.QtCore.QCoreApplication.Encoding = CodecForTr)
PySide.QtCore.QCoreApplication.translate(str, str, str, PySide.QtCore.QCoreApplication.Encoding, int)

I was trying to compile .ui files like how it is being done in #88 compiling resources . And this always generates a bunch of translate lines.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions