mirror of https://github.com/status-im/qzxing.git
Merge pull request #41 from ChALkeR/patch-3
README: add lang to code blocks for highlighting
This commit is contained in:
commit
3c18b88aed
89
README.md
89
README.md
|
@ -22,14 +22,18 @@ Supports barcode decoding for the following types:
|
|||
The project can be used in two ways:
|
||||
## Embed the source code.
|
||||
Copy source code folder of QZXing to the root of your project. Add the following line to your .pro file. For more information see [here](https://github.com/ftylitak/qzxing/wiki/Using-the-QZXing-through-the-source-code).
|
||||
|
||||
include(QZXing/QZXing.pri)
|
||||
|
||||
```qmake
|
||||
include(QZXing/QZXing.pri)
|
||||
```
|
||||
|
||||
## Compile the project as an external library
|
||||
Open QZXing project (QZXing.pro) and compile. If it is needed to compile as static library, uncomment the following line in the .pro file.
|
||||
|
||||
CONFIG += staticlib
|
||||
|
||||
|
||||
```qmake
|
||||
CONFIG += staticlib
|
||||
```
|
||||
|
||||
## Control dependencies
|
||||
Project file config tags are now introduced to be able to control the dependencies of the library accoring to the needs.
|
||||
The core part requires only "core" and "gui" Qt modules. Though for backward compatibility "quick" Qt module is also required.
|
||||
|
@ -43,13 +47,17 @@ Warning! The initial default configuration till 20/03/2017 was including qzxing_
|
|||
### QZXing (core + QML)
|
||||
If an application is going to use QML functionality, it is now possible to add the dependency to it. This can be done by adding the folloing line to the .pro file of its project:
|
||||
|
||||
CONFIG += qzxing_qml
|
||||
```qmake
|
||||
CONFIG += qzxing_qml
|
||||
```
|
||||
|
||||
### QZXing + QZXingFilter
|
||||
QZXing includes QZXingFilter, a QAbstractVideoFilter implementation to provide a mean of providing live feed to the decoding library. It automatically includes QML implementation as well.
|
||||
This option requires "multimedia" Qt module this is why it is considered as a separate configuration. It can be used by adding the folloing line to the .pro file of a project:
|
||||
|
||||
CONFIG += qzxing_multimedia
|
||||
```qmake
|
||||
CONFIG += qzxing_multimedia
|
||||
```
|
||||
|
||||
# How to use
|
||||
|
||||
|
@ -57,54 +65,59 @@ Follows simple code snippets that brefly show the use of the library. For more d
|
|||
|
||||
## C++/Qt
|
||||
|
||||
|
||||
#include <QZXing.h>
|
||||
```cpp
|
||||
#include <QZXing.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
QImage imageToDecode("file.png");
|
||||
QZXing decoder;
|
||||
decoder.setDecoder( DecoderFormat_QR_CODE | DecoderFormat_EAN_13 );
|
||||
QString result = decoder.decodeImage(imageToDecode);
|
||||
}
|
||||
int main()
|
||||
{
|
||||
QImage imageToDecode("file.png");
|
||||
QZXing decoder;
|
||||
decoder.setDecoder( DecoderFormat_QR_CODE | DecoderFormat_EAN_13 );
|
||||
QString result = decoder.decodeImage(imageToDecode);
|
||||
}
|
||||
```
|
||||
|
||||
## QML
|
||||
|
||||
First register QZXing type to the QML engine.
|
||||
|
||||
#include <QZXing.h>
|
||||
```cpp
|
||||
#include <QZXing.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
...
|
||||
QZXing::registerQMLTypes();
|
||||
...
|
||||
}
|
||||
int main()
|
||||
{
|
||||
...
|
||||
QZXing::registerQMLTypes();
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
The in the QML file
|
||||
|
||||
import QZXing 2.3
|
||||
```qml
|
||||
import QZXing 2.3
|
||||
|
||||
function decode(preview) {
|
||||
imageToDecode.source = preview
|
||||
decoder.decodeImageQML(imageToDecode);
|
||||
}
|
||||
function decode(preview) {
|
||||
imageToDecode.source = preview
|
||||
decoder.decodeImageQML(imageToDecode);
|
||||
}
|
||||
|
||||
Image{
|
||||
id:imageToDecode
|
||||
}
|
||||
Image{
|
||||
id:imageToDecode
|
||||
}
|
||||
|
||||
QZXing{
|
||||
id: decoder
|
||||
QZXing{
|
||||
id: decoder
|
||||
|
||||
enabledDecoders: QZXing.DecoderFormat_QR_CODE
|
||||
enabledDecoders: QZXing.DecoderFormat_QR_CODE
|
||||
|
||||
onDecodingStarted: console.log("Decoding of image started...")
|
||||
onDecodingStarted: console.log("Decoding of image started...")
|
||||
|
||||
onTagFound: console.log("Barcode data: " + tag)
|
||||
onTagFound: console.log("Barcode data: " + tag)
|
||||
|
||||
onDecodingFinished: console.log("Decoding finished " + (succeeded==true ? "successfully" : "unsuccessfully") )
|
||||
}
|
||||
onDecodingFinished: console.log("Decoding finished " + (succeeded==true ? "successfully" : "unsuccessfully") )
|
||||
}
|
||||
```
|
||||
|
||||
# contact
|
||||
In case of bug reports or feature requests feel free to open an [issue](https://github.com/ftylitak/qzxing/issues).
|
||||
|
|
Loading…
Reference in New Issue