标题:trutf8编译出错????
作者:skyling2001
日期:2006-09-06 13:18
内容:
源码:
#include
#include
#include
#include
#include
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: *** 错误 1
请问这是什么原因造成的,tr()也是同样的出错。谢谢大家!
#1 [skyling2001 09-06 13:30]
我用的是qte 2.3.7的库,刚才查了一下QObject.h,发现没有trutf8(),请问这个版本怎么使用中文?谢谢!