QT excuse me is there any way to XML format, as the report template, displayed in the window, and then print out,
If there is a code or a link to the introduction, the best, thanks a lot,
CodePudding user response:
Use the following code simple implementation, their mark:QString ReadFile (QString filename)
{
QFile file (filename);
if (! File. The open (QFile: : ReadOnly | QFile: : Text))
{
Return "";
}
QTextStream (in & amp; The file);
In setCodec (" utf-8 ");
QString myText=in readAll ();
File. The close ();
Return myText.
}
Void ExamReportMainWidget: : ReadReport ()
{
QString reportContent=ReadFile (" E: \ \ Report XML ");
UI. LblReport - & gt; SetText (reportContent);
}
Void ExamReportMainWidget: : InitReport ()
{
QString begin=QString: : fromLocal8Bit (" & lt; HTML> <body>
Form the test & lt;/TD> | | | | | | | | QString mid=QString: : fromLocal8Bit (" & lt; TR> | " ); QString end=QString: : fromLocal8Bit (" & lt;/TABLE> |