PDA

View Full Version : how to print QTable?



coralbird
28th March 2007, 08:23
How can I print QTable?QTable doesn't provide function for printing.
Thanks a lot!

zeki709
28th March 2007, 16:36
You can write print code yourself, such as:
QPrinter printer(QPrinter::HighResolution);
printer.setOutputFileName("print.ps");
QPainter painter;
painter.begin(&printer);

for (int page = 0; page < numberOfPages; ++page) {

// Use the painter to draw on the page.

if (page != lastPage)
printer.newPage();
}

painter.end();

Jimmy2775
28th March 2007, 18:52
Alternatively you could build build a HTML table based on your data, put it in a QTextDocument and print that. Depending on your requirements, this may be easier or faster.

coralbird
30th March 2007, 06:05
thanks a lot!!