Qt-interest Archive, March 2008
Howto print a QTableView
Message 1 in thread
Hi,
is there an easy way to print a QTableView on multiple pages?
Nicola
--
[ signature omitted ]
Message 2 in thread
On Thursday 20 March 2008 09:55:17 nicola wrote:
> Hi,
> is there an easy way to print a QTableView on multiple pages?
>
> Nicola
yes. very easy. just render it to a printer.
void QWidget::render ( QPaintDevice * target, const QPoint & targetOffset =
QPoint(), const QRegion & sourceRegion = QRegion(), RenderFlags renderFlags =
RenderFlags( DrawWindowBackground | DrawChildren ) )
or the more complex way if you want to play around with it before printing,
just grab it to a pixmap:
QPixmap QPixmap::grabWidget ( QWidget * widget, int x = 0, int y = 0, int
width = -1, int height = -1 ) [static]
--
[ signature omitted ]
Message 3 in thread
On 20.03.08 10:48:01, Arvid Ephraim Picciani wrote:
> On Thursday 20 March 2008 09:55:17 nicola wrote:
> > Hi,
> > is there an easy way to print a QTableView on multiple pages?
> >
> > Nicola
> yes. very easy. just render it to a printer.
>
> void QWidget::render ( QPaintDevice * target, const QPoint & targetOffset =
> QPoint(), const QRegion & sourceRegion = QRegion(), RenderFlags renderFlags =
> RenderFlags( DrawWindowBackground | DrawChildren ) )
>
> or the more complex way if you want to play around with it before printing,
> just grab it to a pixmap:
>
> QPixmap QPixmap::grabWidget ( QWidget * widget, int x = 0, int y = 0, int
> width = -1, int height = -1 ) [static]
Neither of the two will work when the table has more data than fits onto
the screen.
Andreas
--
[ signature omitted ]
Message 4 in thread
On Thursday 20 March 2008 12:15:57 Andreas Pakulat wrote:
> Neither of the two will work when the table has more data than fits onto
> the screen.
>
> Andreas
true. i'd try QScrollArea::widget() then.
--
[ signature omitted ]
Message 5 in thread
On 20.03.08 09:55:17, nicola wrote:
> Hi,
> is there an easy way to print a QTableView on multiple pages?
No, you'll have to use the model to iterate over the table data and
"paint" that on the QPrinter with a QPainter yourself. Or you could
create a QTextDocument with a table on it and then use
QTextDocument::print()
Andreas
--
[ signature omitted ]
Message 6 in thread
On Thursday 20 March 2008 12:16:50 Andreas Pakulat wrote:
> On 20.03.08 09:55:17, nicola wrote:
> > Hi,
> > is there an easy way to print a QTableView on multiple pages?
>
> No, you'll have to use the model to iterate over the table data and
> "paint" that on the QPrinter with a QPainter yourself. Or you could
> create a QTextDocument with a table on it and then use
> QTextDocument::print()
>
> Andreas
uh no. you can easily just use the delegate if my other idea doesn't work.
void QItemDelegate::paint ( QPainter * painter, const QStyleOptionViewItem &
option, const QModelIndex & index ) const [virtual]
--
[ signature omitted ]