Details
-
Suggestion
-
Resolution: Unresolved
-
P3: Somewhat important
-
4.2.2
-
None
Description
Qt 4.3 introduces a "cosmetic" properites for pens, so that pens with a width != 0 can be ignored by the transformation, and render the width in device coordinates.
Brushes however will always scale, which is not always wanted. It is possible to set the brush's matrix to be the inverse of the painter matrix, but this is very cumbersome when using a high-level framework like QGraphicsView. A "cosmetic" property for brushes would be quite useful.
#include <qapplication.h> #include <qpainter.h> class Widget : public QWidget { public: Widget() { } protected: void paintEvent(QPaintEvent *e) { QPainter painter(this); QPen pen(Qt::red, 5); pen.setCosmetic(true); painter.setPen(pen); QBrush brush(Qt::BDiagPattern); painter.setBrush(brush); painter.drawRect(10, 10, 100, 100); painter.scale(2.0, 2.0); painter.drawRect(150, 10, 100, 100); } }; int main (int argc, char** argv) { QApplication app(argc, argv); Widget w; w.show(); return app.exec(); }