Splatify
7th March 2011, 19:25
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:
//Select a printer
QPrinter printer;
QPrintDialog *dialog = new QPrintDialog(&printer, this);
dialog->setWindowTitle("Print Document");
dialog->exec();
//Create a text document:
QTextDocument doc;
// I think I need some code here which adds all the elements.
//This is the part I'm getting confused with.
//Print the document
doc.print(&printer);
Could someone please give me some guidance, perhaps some example code?
Thanks for your time and trouble
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:
//Select a printer
QPrinter printer;
QPrintDialog *dialog = new QPrintDialog(&printer, this);
dialog->setWindowTitle("Print Document");
dialog->exec();
//Create a text document:
QTextDocument doc;
// I think I need some code here which adds all the elements.
//This is the part I'm getting confused with.
//Print the document
doc.print(&printer);
Could someone please give me some guidance, perhaps some example code?
Thanks for your time and trouble