12 #include <QtPrintSupport> 18 m_pprinter =
new QPrinter;
36 QPrintDialog dlg(m_pprinter,
this);
39 if (dlg.exec() == QDialog::Accepted) {
47 QPainter painter(ppd);
48 QRect r(painter.viewport());
50 painter.setBrush(Qt::white);
52 painter.drawLine(0, 0, r.width(), r.height());
53 painter.drawLine(r.width(), 0, 0, r.height());
55 painter.setBrush(Qt::NoBrush);
56 painter.setPen(QPen(Qt::red, 3, Qt::DashLine));
57 painter.drawEllipse(r);
59 painter.setPen(Qt::blue);
60 painter.setFont(QFont(
"Times", 20, QFont::Normal));
61 painter.drawText(r, Qt::AlignCenter,
"Printer Test");
void draw(QPaintDevice *ppd)
virtual void paintEvent(QPaintEvent *pe)