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

Cosmetic Brushes

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P3: Somewhat important
    • Some future release
    • 4.2.2
    • GUI: Painting
    • 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();
      }
      

      Attachments

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

        Activity

          People

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

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes