源码:
#include <qapplication.h>
#include <qwidget.h>
#include <qpushbutton.h>
#include <qfont.h>
#include <qstring.h>
class MyMainWindow :public QWidget
{
public:
MyMainWindow();
private:
QPushButton *b1;
};
MyMainWindow::MyMainWindow()
{
//QString ch;
b1 = new QPushButton( this,"b1" );
b1->setText( trUtf8( "\xe4\xb8\xad\xe6\x96\x87 中文" ) );
b1->setGeometry( 20, 20, 300, 300 );
b1->setFont( QFont( "Times", 18, QFont::Bold ) );
}
void main( int argc, char **argv )
{
QApplication a( argc, argv );
MyMainWindow w;
a.setMainWidget( &w );
w.show();
a.exec();
}
编译错误:
Debian:/home/yanfeng/Desktop/testqt/chinese2# make
arm-linux-g++ -c -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -DNO_DEBUG -I/develope/qt-2.3.7/include -o test.o test.cpp
test.cpp: In method `MyMainWindow::MyMainWindow()':
test.cpp:20: implicit declaration of function `int trUtf8(...)'
test.cpp:20: no matching function for call to `QPushButton::setText (int)'
/develope/qt-2.3.7/include/qbutton.h:73: candidates are: void QButton::setText(const QString &)
test.cpp: At top level:
test.cpp:28: return type for `main' changed to `int'
make: *** [test.o] 错误 1
请问这是什么原因造成的,tr()也是同样的出错。谢谢大家!