|
主窗口的标题,如何才能显示中文
[code:1]
#include <qapplication.h>
#include <qmainwindow.h>
#include <qpushbutton.h>
#include <qmessagebox.h>
#include <qobject.h>
#include <qtextcodec.h>
int main(int argc, char *argv[])
{
int retCode;
QApplication qApp(argc, argv);
// QPushButton *pb = new QPushButton;
QMainWindow *mw = new QMainWindow;
qApp.setMainWidget(mw);
qApp.setDefaultCodec(QTextCodec::codecForName("GBK"));
retCode = QMessageBox::question(mw,
QObject::tr("Seis"),
QObject::tr("Can you see chinese characters(中文)?"),
QMessageBox::Yes,
QMessageBox::No);
switch(retCode)
{
case QMessageBox::Yes: // yes
mw->setCaption(QObject::tr("主窗口"));
break;
case QMessageBox::No: // no
default:
break;
}
mw->show();
return qApp.exec();
}
[/code:1] |
|