You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

26 lines
631 B

#include "qrcode_utils.h"
#include "ZXingQt.h"
QImage generateQRCode(const QString& text, int moduleSize)
{
using namespace ZXingQt;
auto barcode = Barcode::fromText(text, BarcodeFormat::QRCode);
if (!barcode.isValid())
return {};
WriterOptions opts;
if (moduleSize > 0)
opts.scale(moduleSize);
return barcode.toImage(opts);
}
QStringList readQRCodes(const QImage& image)
{
using namespace ZXingQt;
auto results = ReadBarcodes(image);
QStringList texts;
for (const auto& b : results) {
if (b.isValid())
texts.append(b.text());
}
return texts;
}