Skip to content

Commit

Permalink
set background transparent
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyTheCo committed Sep 11, 2022
1 parent 50a3b9b commit 6e9b4c6
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions QtQrGen/Qrimageprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ using namespace qrcodegen;

QPixmap QRImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
{
const int width = 100;
const int width = 100;

const auto max=(requestedSize.width()>requestedSize.height())?requestedSize.width():requestedSize.height();
const auto max=(requestedSize.width()>requestedSize.height())?requestedSize.width():requestedSize.height();

QPixmap pixmap(max > 0 ? max : width,
max> 0 ? max : width);
QPixmap pixmap(max > 0 ? max : width,
max> 0 ? max : width);
pixmap.fill( Qt::transparent );
*size = pixmap.size();
const QrCode qr = QrCode::encodeText(id.toStdString().c_str(), static_cast<QrCode::Ecc>(errC));
const auto qrSVGstr=toSvgString(qr, color.name().toStdString());

*size = pixmap.size();
const QrCode qr = QrCode::encodeText(id.toStdString().c_str(), static_cast<QrCode::Ecc>(errC));
const auto qrSVGstr=toSvgString(qr, color.name().toStdString());
auto qrImage=QSvgRenderer(QByteArray::fromStdString(qrSVGstr));
QPainter Painter;

auto qrImage=QSvgRenderer(QByteArray::fromStdString(qrSVGstr));
QPainter Painter;

Painter.begin(&pixmap);
qrImage.render(&Painter);
Painter.end();
return pixmap;
Painter.begin(&pixmap);
qrImage.render(&Painter);
Painter.end();
return pixmap;
}

0 comments on commit 6e9b4c6

Please sign in to comment.