[SOLVED]print html text
-
Hello,
I want to propose an option to the user that would allow him to print the content of a QTextEdit with html content.
I try this (Text is my QTextEdit) :
@
QString html = Text->toHtml();QPrinter printer(QPrinter::HighResolution); QPrintDialog printDialog(&printer; , this); if (printDialog.exec()) { QPainter painter(&printer;); QTextDocument textDocument; textDocument.setHtml(html); textDocument.print(&printer;); }@
The dialog box opens in chose a printer, but the document created is empty.
Could you help me understand why?Thanks
-
Why are you creating a QPainter?
-
Sorry, the painter is useless, I solved the problem.
Here's the solution if some are interest :
@
QPrinter Printer(QPrinter::HighResolution);
QString htmlText(Text->toHtml());
QPrintDialog PrintDialog(&Printer;, this);
if (PrintDialog.exec())
{
Printer.setFullPage(true);
QTextDocument TextDocument;
TextDocument.setHtml(htmlText);
TextDocument.print(&Printer;);
}@tha,ks