tests/tr-non-literal/main.cpp
raw| 1 | #include <QtCore/QString> |
| 2 | #include <QtCore/QObject> |
| 3 | |
| 4 | extern void takesString(QString); |
| 5 | extern const char* returnsChar(); |
| 6 | |
| 7 | void test() |
| 8 | { |
| 9 | QString s; |
| 10 | QObject::tr("test"); // OK |
| 11 | QObject::tr(""); // OK |
| 12 | QObject::tr(s.toUtf8()); // Warn |
| 13 | } |
| 14 | |
| 15 | class MyObject : public QObject |
| 16 | { |
| 17 | public: |
| 18 | void test() |
| 19 | { |
| 20 | takesString(tr("hello")); // OK |
| 21 | takesString(tr(returnsChar())); // Warning |
| 22 | } |
| 23 | }; |