Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-483

Cosmetic Brushes

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • Some future release
    • 4.2.2
    • GUI: Painting
    • None

      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();
      }
      

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Unassigned Unassigned
            vhilshei Volker Hilsheimer
            Votes:
            3 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes