-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
3 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,9 @@ | ||
# QtQrGen | ||
# QtQrDec | ||
|
||
This code produce a library with a custom ImageProvider of Qt. The image provider print a QRCODE from a string. | ||
You can play with the resulting ImageProvider on [this page](https://eddytheco.github.io/qmlonline/wasm/index.html?example_url=https://raw.githubusercontent.com/EddyTheCo/qmlonline/main/wasm/examples/qt_qr_gen). An example on how to add the ImageProvider to your project can be found on [this repository](https://github.com/EddyTheCo/qmlonline) (Only the parts enclosed in the USE_QtQrGen macros). | ||
This repo produce a library with a qml type object capable of detect and decode QRCodes on a picture. | ||
This is in development, but you could follow the folder [test](tests/) as a use case example. | ||
|
||
In general CMake produce the target 'QtQrGen' so one can link to this library like | ||
``` | ||
target_link_libraries(<target> <PRIVATE|PUBLIC|INTERFACE> QtQrGen) | ||
``` | ||
|
||
|
||
## Showing the QRCODE on QML aplications will be as simple as | ||
``` | ||
Image { | ||
sourceSize.width: 300 | ||
source: "image://qrcode/https://eddytheco.github.io/" | ||
} | ||
``` | ||
|
||
For this to work one has to add the custom ImageProvider to the QML engine like in the following main.cpp | ||
``` | ||
#include <QGuiApplication> | ||
#include <QQmlApplicationEngine> | ||
#include "Qrimageprovider.hpp" | ||
int main(int argc, char *argv[]) | ||
{ | ||
QGuiApplication app(argc, argv); | ||
QQmlApplicationEngine engine; | ||
engine.addImageProvider(QLatin1String("qrCode"), new QRImageProvider("blue",1)); | ||
const QUrl url(u"qrc:/app/main.qml"_qs); | ||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, | ||
&app, [url](QObject *obj, const QUrl &objUrl) { | ||
if (!obj && url == objUrl) | ||
QCoreApplication::exit(-1); | ||
}, Qt::QueuedConnection); | ||
engine.load(url); | ||
return app.exec(); | ||
} | ||
``` | ||
|
||
|