Home > Mobile >  For a method of QT inspection report is generated
For a method of QT inspection report is generated

Time:09-25

Now need to use QT generating reports, similar to a hospital checking reports that,
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> " );
QString mid=QString: : fromLocal8Bit (" & lt; TR> " );
QString end=QString: : fromLocal8Bit (" & lt;/TABLE> " );
QString mid2=mids. Arg (1). Arg (2). Arg (3). Arg (4). Arg (5). Arg (6). Arg (7). Arg (8);
QString mid3=mids. Arg (" a "). Arg (" b "). Arg (" c "). Arg (" d "). Arg (" e "). Arg (" f "). Arg (" g "). Arg (" h ");
The begin. Append (mid2);
The begin. Append (mid3);
The begin. Append (end);
UI. LblReport - & gt; SetText (begin);
}

CodePudding user response:

There is a control called Textbrowser... It seems, isn't it

CodePudding user response:

refer to the second floor it is a nice nickname response:
there is a control called Textbrowser... Seems to be, is it

Is there any sample code, posted to look at, thank you oh.

CodePudding user response:

reference aqbeyond reply: 3/f
Quote: refer to the second floor it is a nice nickname response:

There is a control called Textbrowser... Seems to be, is it

Is there any sample code, posted to look at, thank you oh,


 # include & lt; QTextBrowser> 

QTextBrowser t;
T.s etText (" ");
T.s etHtml (" ");
T.t oPlainText ();
T.t oHtml ();


SetText write general string is similar to the Label, only can load the Html, you can through the method of export or Html string, usage and basic pages, only a few individual small hole, it may also be because I don't understand Html caused by writing,
  •  Tags:  
  • Qt
  • Related
Form the test & lt;/TD>