Skip to content

Commit

Permalink
qt, refactor: Limit scope of QPainter object
Browse files Browse the repository at this point in the history
  • Loading branch information
hebasto committed Aug 23, 2020
1 parent 197450f commit 8071c75
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/qt/qrimagewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ bool QRImageWidget::setQR(const QString& data, const QString& text)

QImage qrAddrImage = QImage(QR_IMAGE_SIZE, QR_IMAGE_SIZE + (text.isEmpty() ? 0 : 20), QImage::Format_RGB32);
qrAddrImage.fill(0xffffff);
{
QPainter painter(&qrAddrImage);
painter.drawImage(0, 0, qrImage.scaled(QR_IMAGE_SIZE, QR_IMAGE_SIZE));

Expand All @@ -82,8 +83,8 @@ bool QRImageWidget::setQR(const QString& data, const QString& text)
paddedRect.setHeight(QR_IMAGE_SIZE+12);
painter.drawText(paddedRect, Qt::AlignBottom|Qt::AlignCenter, text);
}
}

painter.end();
setPixmap(QPixmap::fromImage(qrAddrImage));

return true;
Expand Down

0 comments on commit 8071c75

Please sign in to comment.