Hi
I need to print a series of small images (QR codes); 3 * 9 per page, total ~30 pages. The following code is called repeatedly.
...
#ifdef QT_DEBUG
painter.setPen(Qt::darkRed);
painter.drawRect(textRect[Use4bbImage]);
bbcode.
save(QString(QStringLiteral
("%1_%2.jpg")).
arg(printQuery.
value(0).
toInt()).
arg(printQuery.
value(1).
toInt()),
0,
100);
qDebug() << "draw image" << bbcode << bbcode.rect() << "on" << textRect[Use4bbImage];
#endif
painter.drawImage(textRect[Use4bbImage], bbcode, bbcode.rect());
QImage bbcode;
...
#ifdef QT_DEBUG
painter.setPen(Qt::darkRed);
painter.drawRect(textRect[Use4bbImage]);
bbcode.save(QString(QStringLiteral("%1_%2.jpg")).arg(printQuery.value(0).toInt()).arg(printQuery.value(1).toInt()), 0, 100);
qDebug() << "draw image" << bbcode << bbcode.rect() << "on" << textRect[Use4bbImage];
#endif
painter.drawImage(textRect[Use4bbImage], bbcode, bbcode.rect());
To copy to clipboard, switch view to plain text mode
The debug output:
draw image QImage(QSize(140, 140) ) QRect(0,0 140x140) on QRect(0,0 2000x2000)
To copy to clipboard, switch view to plain text mode
Strangely, only appproximately half of the images are printed (on some pages almost all, on others only a few). The code above confirms that all three parameters to painter.drawImage are correct: the textRect[Use4bbImage] is the correct QRect (as the darkRed frame is drawn around the place where the image should be placed), the image bbcode exists (as it is correctly saved to a file), bbcode.rect() is always the same size (as per debug output).
I use Qt 5.3.1 on linux (Ubuntu 12.04 LTS). The issue remains whether I print to pdf or whether I print to a real printer.
Any ideas? How should I proceed to find the bug?
Al_
Bookmarks