I18n

xiaoxiao2021-03-06  72

#include #include #include #include #include

/ / I will give you two ways, you look at it. Which method uses you to note another? #Define method1 // # Define method2

#ifdef method2qtextcodec * gp_codec; #ENDIF

Class testdlg: public qdialog {public: testdlg (qwidget * parent = 0, const char * name = 0, BOOL MODAL = FALSE, WFLAGS f = 0); ~ TestDLG ();

Testdlg :: TestDLG (Qwidget * Parent / * = 0 * /, const char * name / * = 0 * /, bool modal / * = false * /, wflags f / * = 0 * /): QDialog (Parent, Name , Modal, f) {qlabel * lbl_title = new qlabel (this, "lbl_title", 0);

Qstring str = "test"; #if defined (method1) lbl_title-> settext (trick); # Elif Defined (Method2) LBL_TITLE-> Settext (gp_codec-> Tounicode (STR)); # endif lbl_title-> setGeometry (10, 10, lbl_title-> sizehint (). Width (), lbl_title-> sizehint (). Height ());

Testdlg :: ~ Testdlg () {}

int main (int argc, char ** argv) {QApplication app (argc, argv); # if defined (METHOD1) QTextCodec * pCodec = QTextCodec :: codecForName ( "GB2312"); app.setDefaultCodec (pCodec); # elif defined (Method2) GP_CODEC = QTextCodec :: CodecForname ("GB2312"); # Endif Testdlg Dialog (0, 0, True); App.SetMainWidget (& Dialog);

Dialog.exec ();

Return 0;}

转载请注明原文地址:https://www.9cbs.com/read-108641.html

New Post(0)