qtopia 显示中文

来源:互联网 发布:淘宝全屏海报怎么做 编辑:程序博客网 时间:2024/06/06 19:02

在板子上显示中文

宿主机的环境变量LANG="zh_CN.GBK"

include <qapplication.h>
#include <qpushbutton.h>
#include <qfont.h>
#include <qvbox.h>
#include <qtextcodec.h>
#include <qstring.h>
#include <qobject.h>
int main(int argc, char **argv)
{
        QApplication a(argc,argv);
        a.setDefaultCodec(QTextCodec::codecForName("GBK"));
        QVBox box;
        box.resize(200,120);
        QCString chinese_string="Í˳ö";

        QTextCodec* pcodec=QTextCodec::codecForName("gbk") ;
        QPushButton quit(QObject::tr(chinese_string),&box);
        quit.setFont( QFont( "unifont", 18, QFont::Bold ) );
        QObject::connect(&quit,SIGNAL(clicked()),&a,SLOT(quit()));
        a.setMainWidget(&box);
        box.show();
        return a.exec();

原创粉丝点击