Skip to content

Commit d439f1c

Browse files
committed
added QObject tr decorator
1 parent 799982b commit d439f1c

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/PythonQtStdDecorators.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
#include "PythonQtStdDecorators.h"
4343
#include "PythonQt.h"
4444
#include "PythonQtClassInfo.h"
45-
45+
#include <QCoreApplication>
4646

4747
bool PythonQtStdDecorators::connect(QObject* sender, const QByteArray& signal, PyObject* callable)
4848
{
@@ -153,3 +153,9 @@ QVariantList PythonQtStdDecorators::children(QObject* o)
153153
}
154154
return v;
155155
}
156+
157+
QString PythonQtStdDecorators::tr(QObject* obj, const QByteArray& text, const QByteArray& ambig, int n)
158+
{
159+
return QCoreApplication::translate(obj->metaObject()->className(), text.constData(), ambig.constData(), QCoreApplication::CodecForTr, n);
160+
}
161+

src/PythonQtStdDecorators.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ public slots:
9191
int static_Qt_qrand() { return qrand(); }
9292
void static_Qt_qsrand(uint a) { qsrand(a); }
9393

94+
QString tr(QObject* obj, const QByteArray& text, const QByteArray& text = QByteArray(), int n = -1);
95+
9496
QByteArray static_Qt_SIGNAL(const QByteArray& s) { return QByteArray("2") + s; }
9597
QByteArray static_Qt_SLOT(const QByteArray& s) { return QByteArray("1") + s; }
9698

0 commit comments

Comments
 (0)