Hi all I have multiple elements I wish to print.

I have a label, a textedit and I have a tableview full of data which I wish to print. I assume that I need to add all of these into a single document and then print the document. I was wondering how to add all of these items to a single document and then print it?

So far the code I have is:

Qt Code:
  1. //Select a printer
  2. QPrinter printer;
  3.  
  4. QPrintDialog *dialog = new QPrintDialog(&printer, this);
  5. dialog->setWindowTitle("Print Document");
  6. dialog->exec();
  7.  
  8. //Create a text document:
  9. // I think I need some code here which adds all the elements.
  10. //This is the part I'm getting confused with.
  11.  
  12. //Print the document
  13. doc.print(&printer);
To copy to clipboard, switch view to plain text mode 

Could someone please give me some guidance, perhaps some example code?


Thanks for your time and trouble