让QT支持中文

来源:互联网 发布:淘宝如何确认收货 编辑:程序博客网 时间:2024/04/29 19:10
被QT1.7-free版不支持中文的问题折磨了很久,终于找到答案了,在main中设置一下编码就OK了。
QTextCodec *my_codec = QTextCodec::codecForName( "GBK");    
QFont l_font("Fangsong Ti");    
#ifdef WIN32
          l_font.setFamily( "宋体");
         l_font.setPointSize(9);
#else
         l_font.setFamily( "Song");
         l_font.setPointSize(12);    
#endif    
app.setDefaultCodec(my_codec);
app.setFont( l_font );
原创粉丝点击