For all last year I used the following code to generate a printout of a report. I loaded a QString var, strHTMLtext, with html markup in order to create formatting. Then I'd create an editor object and use its "setHtml" function to parse the markup code into formatted text.
Then I'd create a document object using the editor object, and send that to the printer.

I't stopped working sometime between September of last year, the end of last year's Homestead season, and this week, the beginning of the new season. The only significant change is the upgrading to 4.2.2.

Here's the code.

Qt Code:
  1. QFont f("TypeWriter",10);
  2. QTextEdit *editor = new QTextEdit(this);
  3. editor->setHtml(strHTMLtext);
  4. editor->setCurrentFont(f);
  5. QTextDocument *document = editor->document();
  6. QPrinter printer;
  7. QPrintDialog *dlg = new QPrintDialog(&printer,this);
  8. if (dlg->exec() == QDialog::Accepted){
  9. document->print(&printer);
  10. }
  11. delete dlg;
  12. delete editor;
To copy to clipboard, switch view to plain text mode 
If I make the editor visible in a window and then send it to the printer I get an good printout, otherwise I get a single, blank page.

As a temporary fix I've created a temp.exe which is an editor app that reads the html file from the HD, and uses setHtml(in.readALL()) to parse it into the editor. Then I print it. It's not the one button click it used to be, but it works.