mottosso / Qt.py

Minimal Python 2 & 3 shim around all Qt bindings - PySide, PySide2, PyQt4 and PyQt5.
MIT License
914 stars 254 forks source link

TypeError: Expected 4 or 5 arguments, got 3. #375

Open jdorr opened 2 years ago

jdorr commented 2 years ago

When compiling ui files using pyside2-uic (PySide-5.15.4), QtCompat.translate() will sometimes have 3 arguments: QtCompat.translate("MainWindow", u"MainWindow", None) When executing our program, TypeError is raised:

  File "/dd/shows/DEV01/user/work.akelada/tools/cent7_64/package/launchpad/0.1.2/python/launchpad/Ui_launchpad_UI.py", line 205, in retranslateUi
    MainWindow.setWindowTitle(QtCompat.translate("MainWindow", u"MainWindow", None))
  File "/dd/tools/cent7_64/package/qt_py/1.3.6/python/Qt.py", line 844, in _translate
    "Expected 4 or 5 arguments, got {0}.".format(len(args) + 2))
TypeError: Expected 4 or 5 arguments, got 3.

I believe a fix should be made to _translate() as it is forcing us to use a certain number of arguments even though in the original methods, some arguments are optional: https://doc.qt.io/qtforpython-5/PySide2/QtCore/QCoreApplication.html#PySide2.QtCore.PySide2.QtCore.QCoreApplication.translate

Also: pyside2-uic foo.ui --> QCoreApplication.translate("MainWindow", u"MainWindow", None) (pyside-5.15.4) pyside2-uic foo.ui --> QCoreApplication.translate("MainWindow", u"MainWindow", None, -1) (pyside-5.12.6)

mottosso commented 2 years ago

So long as this also applies to Qt 4 then a PR is welcome.