Skip to content

Commit 63850d5

Browse files
committed
Update in README.md to include missing info on how to use Barcode Encoder feature. Also added warning (in debug mode) if trying to use Encoder feature through QML through feature is not enabled.
1 parent f5cee9c commit 63850d5

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,14 @@ QZXing{
170170
<a name="howToEncoding"></a>
171171
## Encoding operation
172172

173+
To begin with, make sure the Encoder feature is enabled. If __QZXing.pri__ is used, then the feature is already enabled. If your project uses __QZXing-compoents.pri__ instead, do add the following CONFIG in your .pro file:
174+
175+
```pro
176+
CONFIG += enable_encoder_qr_code
177+
178+
include(QZXing/QZXing-components.pri)
179+
```
180+
173181
<a name="howToEncodingCPP"></a>
174182
### C++/Qt
175183

@@ -204,6 +212,15 @@ QImage barcode = QZXing::encodeData(data, QZXing::EncoderFormat_QR_CODE,
204212
205213
The encoding function can be easily used in QML through QZXing's Image Provider: "image://QZXing/encode/<data_to_be_encoded>". As with the C++ example, it can either be used with the default settings or with custom settings.
206214
215+
First register the custom Image Provider in the __main.cpp__:
216+
217+
```cpp
218+
QQmlApplicationEngine engine;
219+
220+
QZXing::registerQMLTypes();
221+
QZXing::registerQMLImageProvider(engine);
222+
```
223+
207224
Default settings:
208225

209226
```qml

src/QZXingImageProvider.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,16 @@ QImage QZXingImageProvider::requestImage(const QString &id, QSize *size, const Q
7070
data = id.mid(slashIndex + 1);
7171
}
7272

73+
#ifdef ENABLE_ENCODER_GENERIC
7374
QZXingEncoderConfig encoderConfig(format, requestedSize, correctionLevel, border, transparent);
7475

7576
QString dataTemp(QUrl::fromPercentEncoding(data.toUtf8()));
7677

7778
QImage result = QZXing::encodeData(dataTemp, encoderConfig);
79+
#else
80+
QImage result;
81+
qDebug() << "barcode encoder disabled. Add 'CONFIG += enable_encoder_qr_code'";
82+
#endif
7883
*size = result.size();
7984
return result;
8085
}

0 commit comments

Comments
 (0)