wordpress网站扫描工具,织梦网站栏目字体怎么调,视频网站开发流程,网站提升收录一、简介
QZxing开源库: 生成和识别条码和二维码 下载地址#xff1a;https://gitcode.com/mirrors/ftylitak/qzxing/tree/master
二、编译与使用
1.下载并解压#xff0c;解压之后如图所示 2.编译 打开src目录下的QZXing.pro#xff0c;选择合适的编译器进行编译 最后生…一、简介
QZxing开源库: 生成和识别条码和二维码 下载地址https://gitcode.com/mirrors/ftylitak/qzxing/tree/master
二、编译与使用
1.下载并解压解压之后如图所示 2.编译 打开src目录下的QZXing.pro选择合适的编译器进行编译 最后生成库libQZXing3.a和QZXing3.dll 库 三、编写demo测试二维码生成和识别 除了上述两个库还需要源码中的两个头文件 1、在pro包含库和头文件
INCLUDEPATH $$PWD/qzxing/include
LIBS $$PWD/qzxing/libQZXing3.a# 使用生成二维码功能需要加这一句
DEFINES ENABLE_ENCODER_GENERIC2、生成二维码程序
QString text ui-lineEdit-text();if(text.isEmpty())return;QImage img QZXing::encodeData(text,QZXing::EncoderFormat::EncoderFormat_QR_CODE,QSize(200,200),QZXing::EncodeErrorCorrectionLevel::EncodeErrorCorrectionLevel_H,true,false);//图片大小设置与label大小适配//img img.scaled(ui-label-width(), ui-label-height()); //图片适应label有点变形太丑ui-label-setPixmap(QPixmap::fromImage(img));3、识别二维码
QImage img;//QString path qApp-applicationDirPath()//file.png;//第一个参数标准文件对话框的父窗口第二个参数标准文件对话框的标题第三个参数指定默认的目录第四个参数文件过滤器//QString path QFileDialog::getOpenFileName(this,open file dialog,/,png files(*.png);;jpg files(*.jpg));//img.load(path);img ui-label-pixmap()-toImage();if(img.isNull()){qDebug()图片为空;return;}QZXing decode;decode.setDecoder(QZXing::DecoderFormat_QR_CODE);decode.setSourceFilterType(QZXing::TryHarderBehaviour_ThoroughScanning|QZXing::TryHarderBehaviour_Rotate);decode.setSourceFilterType(QZXing::SourceFilter_ImageNormal);QString info decode.decodeImage(img);ui-lineEdit_2-setText(info);4、注意事项 一定要将QZXing3.dll放在和exe同意目录否则会出现编译通过无法运行的问题