To print a content of a HTML file, you would need to use a QTextDocument. I would use something like the following to do it:

HTH

Qt Code:
  1. void print()
  2. {
  3. QFile file("myHTML.html");
  4. if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
  5. return;
  6.  
  7. QString htmlContent;
  8. QTextStream in(&file);
  9. in >> htmlContent;
  10.  
  11. QTextDocument *document = new QTextDocument();
  12. document->setHtml(htmlContent);
  13.  
  14. QPrinter printer;
  15.  
  16. QPrintDialog *dialog = new QPrintDialog(&printer, this);
  17. if (dialog->exec() != QDialog::Accepted)
  18. return;
  19.  
  20. document->print(&printer);
  21.  
  22. delete document;
  23. }
To copy to clipboard, switch view to plain text mode