QTextBrowser: setExtensionType ("html", "text / html; charset = ISO8859-1); setExtensionType (" htm "," text / html; charset = ISO8859-1); setExtensionType ("txt", "text / plain"); setExtensionType ("XML", "text / xml; charset = UTF-8"); if the HTML file is encoded by GB2312, there will be garbled, the method is as follows: QTextBrowser * m_phtmlbrowser; ... ... QMimeSourceFactory * factory = m_phtmlBrowser-> mimeSourceFactory (); factory-> setExtensionType ( "htm", "text / html; charset = GB2312"); factory-> setExtensionType ( "html", "text / html; charset = GB2312 "); factory-> addfactory (factory); ... m_phtmlbrowser-> setsource (filename);