tar -xvf zint-2.6.7.tar.gz
cd zint-2.6.7/backend_qt/
若不依赖png,则编辑backend_qt.pro
DEFINES += ZINT_VERSION="\\\"2.6.7\\\""
改成
DEFINES += NO_PNG ZINT_VERSION="\\\"2.6.7\\\""
默认编译的是静态库,若要编译动态库 则编辑backend_qt.pro
CONFIG += staticlib
#CONFIG += dll
改成
#CONFIG += staticlib
CONFIG += dll
生成Makefile
交叉编译,则调用交叉编译出的qt工具
/usr/local/qt5-arm/bin/qmake
若是pc编译,则调用系统工具
qmake
编译
make
静态编译生成libQtZint.a,动态编译生成libQtZint.so.2.6.7 libQtZint.so.2 libQtZint.so.2.6 libQtZint.so把字符串转成条形码并显示在label上
点击(此处)折叠或打开
- #include "qzint.h"
-
- static QImage Text2QImg(const QString &str)
- {
- Zint::QZint qzint;
- qzint.setSymbol(BARCODE_CODE128);
- qzint.setScale(1);
- qzint.setText(str);
-
- QImage img(480, 320, QImage::Format_RGB888);
- QPainter painter(&img);
- QRectF paintRect(30, 50, 430, 230);
- qzint.render(painter, paintRect);
- return img;
- }
-
- QImage img = Text2QImage("1234567");
- ui->label->setPixmap(QPixmap::fromImage(img));