Fix: don't override the new non-cosmetic default pen in qwidget

As QWidget initializes any painter created in paintevent handler to
have the pen color of the palette's foreground, setting it to 0 width,
i.e. cosmetic, it negated the effect of the recent change to default
1-width non-cosmetic, ref. I04d910e9700baf7f13a8aac07a3633014bb9283e

This caused scaled painting with default pen on QImage and QWidget
to yield different results.

Change-Id: I930b64bf7c0a8c84b9ea3edb49adc813370fed0e
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
This commit is contained in:
aavit 2012-10-23 15:27:18 +02:00 committed by The Qt Project
parent de58eb64bc
commit 52ccbd8911
2 changed files with 3 additions and 3 deletions

View File

@ -11237,7 +11237,7 @@ void QWidget::ungrabGesture(Qt::GestureType gesture)
void QWidget::initPainter(QPainter *painter) const void QWidget::initPainter(QPainter *painter) const
{ {
const QPalette &pal = palette(); const QPalette &pal = palette();
painter->d_func()->state->pen = QPen(pal.brush(foregroundRole()), 0); painter->d_func()->state->pen = QPen(pal.brush(foregroundRole()), 1);
painter->d_func()->state->bgBrush = pal.brush(backgroundRole()); painter->d_func()->state->bgBrush = pal.brush(backgroundRole());
QFont f(font(), const_cast<QWidget *>(this)); QFont f(font(), const_cast<QWidget *>(this));
painter->d_func()->state->deviceFont = f; painter->d_func()->state->deviceFont = f;

View File

@ -2508,8 +2508,8 @@ public:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{ {
dirtyPainter = (painter->pen().width() != 0); dirtyPainter = (painter->pen().color() != Qt::black);
painter->setPen(QPen(Qt::black, 1.0)); painter->setPen(Qt::red);
} }
}; };