Hi,
in the attached testcase the fill pattern of the polygon is painted
outside the polygon.
It's caused by the combination of setWorldMatrix(), drawText() and
save()/restore().
This is on Linux. But as I use the raster engine it should be
reproducible on any platform.
Cheers,
Andre
--
Dipl.-Math. André Wöbbeking
Ingenieurgesellschaft für Verkehrs- und Eisenbahnwesen mbH
Consulting Company for Traffic and Railway Engineering Ltd.
Vahrenwalder Platz 3
30165 Hannover
Germany
phone: +49 511 984228 - 10
fax: +49 511 984228 - 29
web: www.ivembh.de
email: [email protected]
Rechtsform: Gesellschaft mit beschränkter Haftung
Sitz des Unternehmens: Hannover
Amtsgericht Hannover, HRB 56965
Geschäftsführer:
Prof. Dr.-Ing. Thomas Siefer
PD Dr.-Ing. Alfons Radtke
#include <QtGui>
class Widget : public QWidget
{
public:
Widget() : QWidget(0)
{
resize(800, 600);
}
protected:
virtual void paintEvent(QPaintEvent*);
};
void Widget::paintEvent(QPaintEvent*)
{
QImage image(size(), QImage::Format_RGB32);
QPainter imagePainter(&image);
imagePainter.fillRect(rect(), Qt::white);
// draw text
imagePainter.save();
imagePainter.setFont(QFont("Arial", 24));
imagePainter.setPen(Qt::red);
const QMatrix savedMatrix(imagePainter.worldMatrix());
const QMatrix matrix(1, 0, 0, 1, 100, 100);
imagePainter.setWorldMatrix(matrix);
imagePainter.drawText(0, 0, "PW");
imagePainter.setWorldMatrix(savedMatrix);
imagePainter.restore();
// draw polygon
imagePainter.setPen(Qt::blue);
imagePainter.setBrush(QBrush(Qt::black, Qt::BDiagPattern));
int const x(400), y(150);
QPolygon polygon;
polygon << QPoint(x, y)
<< QPoint(x + 14, y - 13)
<< QPoint(x + 192, y - 13)
<< QPoint(x + 205, y)
<< QPoint(x + 192, y + 14)
<< QPoint(x + 14, y + 14)
<< QPoint(x, y);
imagePainter.drawPolygon(polygon);
imagePainter.end();
QPainter widgetPainter(this);
widgetPainter.drawImage(0, 0, image);
}
int main(int argc, char** argv)
{
QApplication app(argc, argv);
Widget widget;
widget.show();
return app.exec();
}
_______________________________________________
Qt4-preview-feedback mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt4-preview-feedback