1 year ago
#238109
Mohamed El Kayal
How do I print the generated QR code using Nayku's library in a pdf file?
I am using a third party library : https://github.com/nayuki/QR-Code-generator using c++. So far what I have reached in my code is printing the QR code in the console.
My app generates a pdf file that I write the data entered in some line editors to. I want to add a QR code in that pdf file being generated as well.
QString Widget::generateQRCode(QString name, QString date, QString address, QString email)
{
QString data = name + date + address + email
;
const char *text = data.toUtf8().constData(); // User-supplied text
const QrCode::Ecc errCorLvl = QrCode::Ecc::LOW; // Error correction level
// Make and print the QR Code symbol
const QrCode qr = QrCode::encodeText(text, errCorLvl);
printQr(qr);
std::cout << toSvgString(qr, 4) << std::endl;
return QString::fromStdString(toSvgString(qr, 4));
}
What I want is to take the output of this function and change it into something I could use the Qpainter class with to insert it into the PDF file.
/*[7] Generate QR Code */
QString qrcode = generateQRCode(name,date,address,email);
qDebug()<<"QRCODE QRCODE QRCODE\n"<<qrcode;
painter.setPen(qRgb(0,0,0));
painter.setFont(QFont("Arial", 15, QFont::Bold));
painter.drawText(500,5000,qrcode);
}
c++
qt
qr-code
qpainter
0 Answers
Your Answer