Results 1 to 4 of 4

Thread: error C3861: 'tr': identifier not found, even with argument-dependent lookup

  1. #1
    Join Date
    Feb 2006
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default error C3861: 'tr': identifier not found, even with argument-dependent lookup

    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.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: error C3861: 'tr': identifier not found, even with argument-dependent lookup

    Use a static method QObject::tr() or QCoreApplication::translate() on line 33.

    PS. Use code blocks around your code to make it more readable.

  3. #3
    Join Date
    Feb 2006
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: error C3861: 'tr': identifier not found, even with argument-dependent lookup

    Quote Originally Posted by jpn
    Use a static method QObject::tr() or QCoreApplication::translate() on line 33.

    PS. Use code blocks around your code to make it more readable.
    Thanks but it is not working, the compiler report the same message.
    Qt Code:
    1. QPushButton *quit = new QPushButton(QObject::tr("Quit"), this);
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: error C3861: 'tr': identifier not found, even with argument-dependent lookup

    Line 33 is
    Qt Code:
    1. btnExit.setText(tr("Exit"));
    To copy to clipboard, switch view to plain text mode 

  5. The following user says thank you to jpn for this useful post:

    Mars (27th February 2006)

Similar Threads

  1. Visual Studio 2005 Express
    By Muzz in forum Installation and Deployment
    Replies: 22
    Last Post: 6th November 2008, 06:21
  2. Program crashes with assert error in xcb_lock.c
    By Valheru in forum Qt Programming
    Replies: 3
    Last Post: 18th November 2007, 19:56
  3. KDE 3.5.0 crash while opening project
    By MarkoSan in forum KDE Forum
    Replies: 2
    Last Post: 19th October 2007, 16:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.