QBarcode is a Qt library allowing to generate barcodes.
Tip
Latest development/pull requests will be committed into main branch.
Each stable release have their dedicated branch:
1.0.x: branchdev/1.01.1.x: branchdev/1.1- etc...
Table of contents :
This cross platform library allow to generate multiple types of barcodes and render those in different format.
We have three "main" classes:
qbar::Payload: This class store only datas to use, representing what we have to encode.qbar::Barcode: This is the base class of all barcodes types, responsible of building the barcode matrix. It don't manage encoding and don't manage appearance.qbar::Renderer: This class allow to render barcodes (size, margins, colors, etc...) and only responsible of how does it look ?
Note
Custom application QBarcodeApp is available and used as a demo application to discover how this library can be used.
What types of barcodes are currently supported:
| Type of barcode | Barcode class | Rendering class | Supported payloads |
|---|---|---|---|
| QrCode | qbar::QrCode |
qbar::RendererQrCode |
- String - URL - Wifi |
Note
🕚 Currently planned: 🕚
- More QrCode payload: geo, phone contact, etc...
- More barcodes types: EAN-13
This library requires at least C++ 17 standard
Below, list of required dependencies:
| Dependencies | VCPKG package | Comments |
|---|---|---|
| Qt | / | Compatible with Qt6.x Compatible with Qt5.15.x |
| Google Test | gtest |
Only needed to run unit-tests |
| libqrencode | libqrencode |
/ |
Note
Dependency manager VCPKG is not mandatory, this is only a note to be able to list needed packages
This library can be use as an embedded library in a subdirectory of your project (like a git submodule for example) :
- In the root CMakeLists, add instructions :
add_subdirectory(qbarcode) # Or if library is put in a folder "dependencies" : add_subdirectory(dependencies/qbarcode)- In the application/library CMakeLists, add instructions :
# Link needed libraries
target_link_libraries(${PROJECT_NAME} PRIVATE qbarcode)This library provide some CMake build options:
QBAR_BUILD_TESTS(default:ON): Use to enable/disable unit-tests build
Please refer to the list of classes documentation for more details.
This library use the PImpl Idiom in order to preserve ABI compatibility (Qt wiki also have a great tutorial on the PImpl idiom).
So only major release (this project use the semantic versioning) should break the ABI.
In order to easily check at compilation time library version (to manage compatibility between multiple versions for example), macro QBAR_VERSION_ENCODE (defined inside library_global.h file) can be used:
#if QBAR_VERSION >= QBAR_VERSION_ENCODE(2,0,0)
// Do stuff for version 2.0.0 or higher
#else
// Do stuff for earlier versions
#endifSince library header used during final application build could differ from the actual library version, it is recommended to use the method:
#include "qbarcode/qbartypes.h"
const QVersionNumber libSemver = qbar::getLibraryVersion();All classes/methods has been documented with Doxygen utility and automatically generated at online website documentation.
Note
This repository contains two kinds of documentation:
- Public API: Available via online website documentation or locally via Doxyfile
docs/fragments/Doxyfile-public-api.in - Internal: Available locally only via
docs/fragments/Doxyfile-internal.in
To generate documentation locally, we can use:
doxygen ./docs/fragments/Doxyfile-nameTip
You can also load the Doxyfile into Doxywizard (Doxygen GUI) and run generation.
This library is licensed under MIT license.