base class for barcode generators To add your own barcode generator, subclass this class and reimplement toImage(const QSizeF&) to do the actual work of generating the barcode.
More...
#include <abstractbarcode.h>
|
| AbstractBarcode () |
| creates a barcode generator without any data
|
|
const QColor & | backgroundColor () const |
|
QByteArray | byteArrayData () const |
| Binary data encoded in this barcode.
|
|
QString | data () const |
| Textual content encoded in this barcode.
|
|
Dimensions | dimensions () const |
| Returns the amount of dimensions of the barcode.
|
|
const QColor & | foregroundColor () const |
|
QSizeF | minimumSize () const |
| The minimal size of this barcode.
|
|
QSizeF | preferredSize (qreal devicePixelRatio) const |
| The recommended size for this barcode when shown on a screen.
|
|
void | setBackgroundColor (const QColor &backgroundcolor) |
| sets the background color
|
|
void | setData (const QByteArray &data) |
| Sets binary data to be drawn as a barcode.
|
|
void | setData (const QString &data) |
| Sets textual data to be drawn as a barcode.
|
|
void | setForegroundColor (const QColor &foregroundcolor) |
| sets the foreground color
|
|
QImage | toImage (const QSizeF &size) |
| Creates a image with a barcode on.
|
|
QSizeF | trueMinimumSize () const |
| The minimal amount of pixels needed to represent this barcode without loss of information.
|
|
|
virtual QImage | paintImage (const QSizeF &size)=0 |
| Doing the actual painting of the image.
|
|
void | setMinimumSize (const QSizeF &minimumSize) |
| Sets the minimum size for this barcode.
|
|
base class for barcode generators To add your own barcode generator, subclass this class and reimplement toImage(const QSizeF&) to do the actual work of generating the barcode.
The barcode is cached in AbstractBarcode when painting and the size and the data doesn't change. Using the same AbstractBarcode to paint on several surfaces, if they aren't of the exact same size will break the caching
◆ Dimensions
Dimensions of the barcode.
- Since
- 5.69
Enumerator |
---|
NoDimensions | Null barcode.
|
OneDimension | One-dimensional barcode.
|
TwoDimensions | 2D matrix code.
|
◆ AbstractBarcode()
Prison::AbstractBarcode::AbstractBarcode |
( |
| ) |
|
◆ backgroundColor()
const QColor & Prison::AbstractBarcode::backgroundColor |
( |
| ) |
const |
- Returns
- the background color (by default white) to be used for the barcode.
◆ byteArrayData()
QByteArray Prison::AbstractBarcode::byteArrayData |
( |
| ) |
const |
Binary data encoded in this barcode.
This returns an empty QByteArray if textual content is set.
- See also
- data()
- Since
- 5.85
◆ data()
QString Prison::AbstractBarcode::data |
( |
| ) |
const |
Textual content encoded in this barcode.
This returns an empty QString if binary content is set.
- See also
- byteArrayData()
◆ dimensions()
Dimensions Prison::AbstractBarcode::dimensions |
( |
| ) |
const |
Returns the amount of dimensions of the barcode.
- Since
- 5.69
◆ foregroundColor()
const QColor & Prison::AbstractBarcode::foregroundColor |
( |
| ) |
const |
- Returns
- the foreground color (by default black) to be used for the barcode.
◆ minimumSize()
QSizeF Prison::AbstractBarcode::minimumSize |
( |
| ) |
const |
The minimal size of this barcode.
- Note
- This isn't the absolute minimum, but closer to the result of preferredSize(1).
- Returns
- the minimal size for this barcode.
- Deprecated:
- Since 5.69, use preferredSize() or trueMinimumSize().
◆ paintImage()
virtual QImage Prison::AbstractBarcode::paintImage |
( |
const QSizeF & |
size | ) |
|
|
protectedpure virtual |
Doing the actual painting of the image.
- Parameters
-
size | unused - will be removed in KF6 |
- Returns
- image with barcode, or null image
◆ preferredSize()
QSizeF Prison::AbstractBarcode::preferredSize |
( |
qreal |
devicePixelRatio | ) |
const |
The recommended size for this barcode when shown on a screen.
This is typically significantly larger than trueMinimumSize() so that barcode scanners tend to reliably detect the code. As this depends on the physical resolution of the output, you have to pass the device pixel ration of the output screen here.
- Parameters
-
devicePixelRatio | The device pixel ratio of the screen this is shown on. |
- See also
- trueMinimumSize
- Since
- 5.69
◆ setBackgroundColor()
void Prison::AbstractBarcode::setBackgroundColor |
( |
const QColor & |
backgroundcolor | ) |
|
sets the background color
- Parameters
-
backgroundcolor | - the new background color |
◆ setData() [1/2]
void Prison::AbstractBarcode::setData |
( |
const QByteArray & |
data | ) |
|
Sets binary data to be drawn as a barcode.
Prefer the QString overload if your content is purely textual, to reduce the risk of encoding issues for non-ASCII content. Calling this function does not do any repaints of anything, they are your own responsibility.
- Parameters
-
data | binary barcode content |
- Since
- 5.85
◆ setData() [2/2]
void Prison::AbstractBarcode::setData |
( |
const QString & |
data | ) |
|
Sets textual data to be drawn as a barcode.
Only use this function if your content is textual, use the QByteArray overload when your content contains non-textual binary content. Calling this function does not do any repaints of anything, they are your own responsibility.
- Parameters
-
data | textual barcode content |
◆ setForegroundColor()
void Prison::AbstractBarcode::setForegroundColor |
( |
const QColor & |
foregroundcolor | ) |
|
sets the foreground color
- Parameters
-
foregroundcolor | - the new foreground color |
◆ setMinimumSize()
void Prison::AbstractBarcode::setMinimumSize |
( |
const QSizeF & |
minimumSize | ) |
|
|
protected |
Sets the minimum size for this barcode.
Some barcodes have minimum sizes for when they are readable and such
- Parameters
-
minimumSize | QSizeF holding the minimum size for this barcode |
- Deprecated:
- since 5.69, function is a no-op, no need to call this anymore.
◆ toImage()
QImage Prison::AbstractBarcode::toImage |
( |
const QSizeF & |
size | ) |
|
Creates a image with a barcode on.
- Returns
- QImage with a barcode on, trying to match the requested
- Parameters
-
If one of the dimensions of
- Parameters
-
size | is smaller than the matching dimension in minimumSize, a null QImage will be returned |
◆ trueMinimumSize()
QSizeF Prison::AbstractBarcode::trueMinimumSize |
( |
| ) |
const |
The minimal amount of pixels needed to represent this barcode without loss of information.
That is, the size of the barcode image if each line or dot is just one pixel wide. On normal screens that is not enough for barcode scanners to reliably detect the barcode though.
- See also
- preferredSize
- Since
- 5.69