网上下载simhei.ttf字体,复制到qt的font所在目录下
#include <qapplication.h>
#include <qpushbutton.h>
#include <QWidget>
#include <QTextCodec>
#include <QLabel>
#include <QFont>
#include <QtGui/QTextEdit>
int main( int argc, char *argv[] )
{
QApplication app(argc, argv);
QFont font;
font.setPointSize(50);
font.setFamily(("simhei"));
app.setFont(font);
QTextCodec::setCodecForTr(QTextCodec::codecForName("utf-8"));
QTextEdit *textEdit=new QTextEdit;
textEdit->setText(QObject::tr("虎年发财"));
textEdit->show();
return app.exec();
}
用户377235 2014-8-1 13:23
用户61522 2010-2-25 14:59
用户34694 2009-12-31 11:40
用户1512856 2008-3-25 18:05