Visual studio 2003 with QT 4 on windows xp professional, compiling the following code fail with message:
main.cpp(33) : error C3861: 'tr': identifier not found, even with argument-dependent lookup
my code:
#include <QApplication>
#include <QFont>
#include <QPushButton>
#include <QWidget>
class MyWidget : public QWidget
{
public:
MyWidget(QWidget *parent = 0);
};
MyWidget::MyWidget(QWidget *parent) :
QWidget(parent)
{
setFixedSize(200, 120);
QPushButton *quit = new QPushButton(QObject::tr("Quit"), this);
quit->setGeometry(62, 40, 75, 30);
quit->setFont(QFont("Times", 18, QFont::Bold));
connect(quit, SIGNAL(clicked()), qApp, SLOT(quit()));
}
int main(int argc, char *argv[])
{
QApplication Application(argc, argv);
QWidget Window;
Window.resize(640, 480);
QPushButton btnExit;
btnExit.setParent(&Window);
btnExit.setText(tr("Exit"));
btnExit.setGeometry(100, 100, 125, 25);
btnExit.setFont(QFont("Fixedsys", 12, QFont::Bold, true));
QObject::connect(&btnExit, SIGNAL(clicked()), &Application, SLOT(quit()));
Window.show();
return Application.exec();
}
anybody help me?thx.
Bookmarks