3

I want to generate the Qr code in QML in QT creator v5.7 so can you please help me to which qr library i will use and how to implement qr code.

TM9412
  • 31
  • 1
  • 3

1 Answers1

4

A solution would be to use the QZXing library: https://github.com/ftylitak/qzxing#howToEncodingQtQuick

The sample usage is quite simple:
Include the library in your project and then in you QML code you can do :

import QZXing 2.3

Image{
    source: "image://QZXing/encode/" + textToBeEncoded
}

If you want to understand how it works under the hood, this library is a wrapper around the famous zxing library and it exposes a QQuickImageProvider that can be invoked from QML with the image url : image://QZXing/....

This image provider takes the text to be encoded and pass it to a c++ function generating a QImage from the data and returns this QImage to the qml engine that will display it.

GrecKo
  • 6,615
  • 19
  • 23