PDA

View Full Version : QtCore.translate



miso
2nd May 2013, 10:45
Hi all!

My original problem is in PyQt (http://stackoverflow.com/questions/16296783/qt-translate-function-call-error), but it probably exists also in C++/Qt.
In short, I have (sometimes) this error:
msg = QtGui.qApp.translate("@default", error_msg)
TypeError: function takes exactly 5 arguments (1 given)

error_msg is always non-empty string, so this error is kind of tricky, it's just a result of another problem (like not initialized QApplication, but in my case I'm sure it's initialized).
This happend only sometimes, for most of the time my application works. I can't reproduce it on smaller piece of code.

My question is: are you experienced with such error? In which cases it happend?

Thank you,
Michal

wysota
2nd May 2013, 10:49
What is the content of error_msg?

miso
2nd May 2013, 13:05
Colleague of mine already solved it. It happens when error_msg contains non ascii characters.
Solution (codec is Latin1 by default):
QtCore.QTextCodec.setCodecForTr(QtCore.QTextCodec. codecForName("UTF-8"))