下载资源后端资源详情
TSCDemo.zip
大小:741.25KB
价格:50积分
下载量:0
评分:
5.0
上传者:yonug1107716573
更新日期:2025-09-22

Qt + TSC 打印机使用

资源文件列表(大概)

文件名
大小
TSCDemo/
-
TSCDemo/main.cpp
183B
TSCDemo/mainwindow.cpp
5.37KB
TSCDemo/mainwindow.h
999B
TSCDemo/mainwindow.ui
1.93KB
TSCDemo/TSCDemo.pro
768B
TSCDemo/TSCDLL_20240124/
-
TSCDemo/TSCDLL_20240124/x64/
-
TSCDemo/TSCDLL_20240124/x64/TSCLIB.dll
1.05MB
TSCDemo/TSCDLL_20240124/x64/TSCLIB.lib
45.59KB
TSCDemo/TSCDLL_20240124/x86/
-
TSCDemo/TSCDLL_20240124/x86/TSCLIB.dll
746KB
TSCDemo/TSCDLL_20240124/x86/TSCLIB.lib
44.77KB

资源内容介绍

Qt + TSC 打印机简单使用,打印条码,二维码,文字 功能
#include "mainwindow.h"#include "ui_mainwindow.h"#include <QDebug>MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), tscdll("TSCLIB.dll") { ui->setupUi(this); about = (TSCabout)tscdll.resolve("about"); openport = (TSCopenport)tscdll.resolve("openport"); closeport = (TSCcloseport)tscdll.resolve("closeport"); sendcommand = (TSCsendcommand)tscdll.resolve("sendcommand"); tscwindowsfont = (TSCwindowsfont)tscdll.resolve("windowsfont"); downloadpcx = (Downloadpcx)tscdll.resolve("downloadpcx");}MainWindow::~MainWindow() { delete ui; }void MainWindow::on_btn_barcode_clicked() { if (!tscdll.load()) { qDebug() << "加载DLL失败!"; } QString text = ui->lE_barcode->text(); QString barCodeCMD = QString("BARCODE %1,%2,\"128\",30,0,0,1,1,\"%3\"") .arg(QString::number(100), QString::number(100), text); // 设置打印机型号 openport("TSC TE244"); // 设置标签纸大小 sendcommand("SIZE 65 mm, 120 mm"); // 设置打印方向 sendcommand("DIRECTION 1"); // 清空打印机缓存 sendcommand("CLS"); // 打印条形码 sendcommand(barCodeCMD.toLocal8Bit().data()); sendcommand("PRINT 1"); closeport();}void MainWindow::on_btn_qrcode_clicked() { if (!tscdll.load()) { qDebug() << "加载DLL失败!"; } QString text = ui->lE_qrcode->text(); QString qrCodeCMD = QString("QRCODE %1,%2,H,6,A,270,\"%3\"") .arg(QString::number(200), QString::number(200), text); // 设置打印机型号 openport("TSC TE244"); // 设置标签纸大小 sendcommand("SIZE 65 mm, 120 mm"); // 设置打印方向 sendcommand("DIRECTION 1"); // 清空打印机缓存 sendcommand("CLS"); // 打印条形码 sendcommand(qrCodeCMD.toLocal8Bit().data()); sendcommand("PRINT 1"); closeport();}void MainWindow::on_btn_font_clicked() { if (!tscdll.load()) { qDebug() << "加载DLL失败!"; } QString text = ui->lE_font->text(); // 设置打印机型号 openport("TSC TE244"); // 设置标签纸大小 sendcommand("SIZE 65 mm, 120 mm"); // 设置打印方向 sendcommand("DIRECTION 1"); // 清空打印机缓存 sendcommand("CLS"); // 打印条形码 tscwindowsfont(16, 64, 20, 0, 2, 0, (unsigned char *)"Arial", (unsigned char *)text.toLocal8Bit().data()); sendcommand("PRINT 1"); closeport();}

用户评论 (0)

发表评论

captcha