PDA

View Full Version : Re: Printing in Qt



Jimmy2775
12th July 2006, 18:00
Does anyone know of any good introductory material regarding printing in Qt? I've seen some pretty good posts about more specific topics in Qt printing here in the forums, but I'm really new to the topic and was hoping to find some basic examples so I can get a sense of what's involved.

From what I've read so far, it seems as though I need to generate a QTextDocument and then paint it using a QPrinter object, but I'm not really clear on the details of the process yet.

Thanks

Jimmy

jpn
12th July 2006, 18:38
Printing a QTextDocument is something as simple as this:


QTextDocument* document = textEdit->document();
QPrinter printer;

QPrintDialog* dialog = new QPrintDialog(&printer, this);
if (dialog->exec() == QDialog::Accepted)
{
document->print(&printer);
}

Jimmy2775
12th July 2006, 19:02
That certainly simplifies things a lot, at least on the printing end. Now I just have to figure out how to generate a QTextDocument...

Thanks jpn

Jimmy2775
12th July 2006, 23:00
I want to use Qt to generate reports. I've had a look at how printing works in Qt (thanks again jpn) and the idea of generating a QTextDocument based on my data seems pretty straightforward. The only issue I'm having is with the concept of page headers and footers. I would like to have a header and footer on each page, and I imagine there is some way to do this once the page size has been determined by the QPrintDialog. Has anyone had any kind of experience with this?

-- Note that this post is appearing at the top of the thread due to date issues with the server. It should appear just after the post where I thanked jpn (12th July 2006, 12:02)