[Qt-interest] Printing (tables) with Qt4

Jan janusius at gmx.net
Tue Nov 17 09:52:52 CET 2009


Hi Manuel,

in my experience printing tables directly is very uncomfortable. I 
suggest you create a html string from your table's contents and add them 
to a QTextdocument. Printing is available from QTextdocument.

Jan

Manuel Argüelles schrieb:
> 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?
> 
> 
> 
> 
> 
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
> 



More information about the Qt-interest-old mailing list