PDA

View Full Version : print QTableWidget



chak_med
3rd November 2006, 13:41
I'm trying to print a QTableWidget so I create a QPixmap like this

QPixmap pixGroupe = QPixmap::grabWidget(this); // this == QTableWidget
QPrinter * printDvce = new QPrinter;
QPainter paintr(printDvce);
paintr.drawPixmap(pixGroupe);

the probleme with this code is that I can't get all the QtableWidget contents in the pixmap,
I've juste get the visible region of the table. (viewport + visible part of the headers ).

is Any one can tell what can I do to print all the content of QtableWidget ?

jpn
3rd November 2006, 13:53
Give this (http://www.qtcentre.org/forum/f-qt-programming-2/t-qtableview-printing-3796.html#10) a try.

chak_med
4th November 2006, 11:18
thank you for this reply.
T tried your code with QPainter's powerful redirecting mecanism.
but the probleme is that I get only the contents ( the viewport()) of the QTableWidget
without the horzontal and the vertical header and without any widget painted inside the content of the table. can you have any Idea ?

I linked to this post a screenshot of the table I want to print(table.jpg)
and the pixmap that I obtained with your code (PrintResult1.jpg)

jpn
4th November 2006, 18:46
the probleme is that I get only the contents ( the viewport()) of the QTableWidget
without the horzontal and the vertical header and without any widget painted inside the content of the table.
So you are using cell widgets? I guess you would have to do the corresponding "redirecting + paint event" -trick for headers and all the cell widgets as well.