[Qt-interest] Printing (tables) with Qt4

Manuel Argüelles manuel.arguelles at gmail.com
Tue Nov 17 02:38:03 CET 2009


Hello List,

I'm relative new to qt and so far it has been a nice experience, however I'm 
having some problems with printing.

I followed the guide about printing 
(http://doc.trolltech.com/4.5/printing.html) and I understand how to set up 
the printer (QPrinter) and settings with QPrintDialog. Also 
QPrintPreviewDialog seems easy too (haven't tried it yet).

My problem is that I have a big QTableView that I need to print, I tried to 
use the render method but it placed a really small image of the table with the 
scroll bars, I tried to set the QRegion to pageRect() but it almost crashed my 
pc (everything got really slow and I had to terminate it)

How can I print a table with headers and grid, and how can I tell when it is 
time to call newPage()?

I read somewhere that I must write to the QPainter directly, this means using 
the drawText method right? but then I'll have to give the coordinates for 
every text, and how can I know how much did it take? I also read about using a 
QTextDocument but I haven't read much about it. I also read about using html, 
but the same applies....

Could someone please give me any hits or point me to some urls with example 
about this?








More information about the Qt-interest-old mailing list