PDA

View Full Version : Printing from QTableView



baray98
18th June 2010, 23:34
I am trying to add print functionality to my custom TableView but i am lost. please help me . where should i start

here's my idea so far

I figure ill use QPrinter and have a QPainter out of it
for all my cell (row,col) i will ask view's delegate to paint it for me given a rect



//i could use this baby
void QItemDelegate::paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const


But now i am stuck on calculating those rects. since QPainter have different DPI's than my monitor, i need to scale it i guess.

the more i think of it the more confused i am ...

Questions:
am i on the right track .. or theres is an easier way to get my objective ?
Can someone show my some snippet on these things?
How can i figure out how many pages should i print since this custom table can be variable rows and cols?

needs some enlightment

baray98