...
//set pens and fonts
pen03.setWidthF(0.3);
pen01.setWidthF(0.1);
//draw the form
painter.begin(printer);
painter.
setWindow(QRect(0,
0,
210,
297));
//set coordinates in millimeters
painter.setPen(pen03);
painter.
drawLine(QLine(20,
50,
195,
50));
painter.
drawLine(QLine(195,
50,
195,
280));
painter.
drawLine(QLine(195,
280,
20,
280));
painter.
drawLine(QLine(20,
280,
20,
50));
painter.
drawLine(QLine(20,
57,
195,
57));
painter.setPen(pen01);
painter.
drawLine(QLine((wordX
- 5),
50,
(wordX
- 5),
280));
painter.
drawLine(QLine((explX
- 5),
50,
(explX
- 5),
280));
painter.setFont(arial10);
painter.drawText(150, 50, "Testing"); // the font printed is *not* 10 points.
...
painter.end();
printer = new QPrinter(QPrinter::PrinterResolution);
...
//set pens and fonts
QPen pen03;
pen03.setWidthF(0.3);
QPen pen01;
pen01.setWidthF(0.1);
QFont arial10("Arial", 10, QFont::Normal);
//draw the form
QPainter painter;
painter.begin(printer);
painter.setWindow(QRect(0, 0, 210, 297)); //set coordinates in millimeters
painter.setPen(pen03);
painter.drawLine(QLine(20, 50, 195, 50));
painter.drawLine(QLine(195, 50, 195, 280));
painter.drawLine(QLine(195, 280, 20, 280));
painter.drawLine(QLine(20, 280, 20, 50));
painter.drawLine(QLine(20, 57, 195, 57));
painter.setPen(pen01);
painter.drawLine(QLine((wordX - 5), 50, (wordX - 5), 280));
painter.drawLine(QLine((explX - 5), 50, (explX - 5), 280));
painter.setFont(arial10);
painter.drawText(150, 50, "Testing"); // the font printed is *not* 10 points.
...
painter.end();
To copy to clipboard, switch view to plain text mode
Bookmarks