TSC TTP-244 Pro打印机QT版本开发

承接开发:QQ786453398

TSC TTP-244 Pro打印机QT版本开发

一、硬件安装

1、根据官方使用手册和视频正确完成打印机的安装,如果缺乏驱动可以到官网下载。驱动链接:https://pan.baidu.com/s/1puw8f0xKftginOvJjkwrLg 提取码: kgu7
在设备管理器上正确显示TTP-244 Pro打印机即正确安装完毕,如下图:

添加打印机

二、软件安装

1、安装供应商提供的【标签打印软件】【Dlabel云标签】,这个软件适合一般用户使用。
Dlabel云标签

标签打印软件可到我的资源里下载,已上传;

三、QT自定义TSC打印机开发

1、去官网下载对应型号的动态库TSCLIB.dll,官网链接:资料下载 | TSC Printers (chinatsc.cn)
2、根据设备情况,下载64位TTP-244 Pro动态库并解压到C盘;
动态库地址

3、QT版本TTP-244 Pro打印机开发示例代码:
.h

#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QDebug>
#include <QMainWindow>
#include <QPushButton>
#include <QWidget>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private:
    Ui::MainWindow *ui;
private slots:
    void handleButton();
private:
    QPushButton *m_button;
};

#endif // MAINWINDOW_H

.cpp

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
#include <QLibrary>
#include <QTextCodec>
#include <QByteArray>
#include <QString>
#include "qmessagebox.h"
#include <QMessageBox>
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{

    ui->setupUi(this);
    connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(handleButton()));

}

MainWindow::~MainWindow()
{

    delete ui;

}

void MainWindow::handleButton()
{
   //QApplication::exit();
   ui->pushButton->setText("Example");

   int result;
   typedef int (*TSCabout)();
   typedef int (*TSCopenport)(char*);
   typedef int (*TSCsendcommand)(char*);
   typedef int (*TSCcloseport)();
   typedef int (*TSCnobackfeed)();

   //你存放TSCLIB.dll的路径
   QLibrary tscdll("C:\\TSCLIB.dll");
   if(tscdll.load())
   {

        TSCabout about=(TSCabout)tscdll.resolve("about");    //add about() function
        TSCopenport openport=(TSCopenport)tscdll.resolve("openport");    //add about() function
        TSCcloseport closeport=(TSCcloseport)tscdll.resolve("closeport");    //add closeport() function
        TSCsendcommand sendcommand=(TSCsendcommand)tscdll.resolve("sendcommand");    //add sendcommand() function
        TSCnobackfeed  nobackfeed =(TSCnobackfeed)tscdll.resolve("nobackfeed");    //add nobackfeed() function

        about();//显示DLL版本号
        openport("TSC TTP-244 Pro"); //指定电脑端的输出口
        nobackfeed();
        sendcommand("SIZE 80 mm. 30 mm");
        sendcommand("DIRECTION 1");
        sendcommand("CLS");
                /*
         * TEXT:文本打印指令
         * 10  :X坐标
         * 150 :Y坐标
         * 2   :字体
         * 0   :旋转角度
         * 1   :放大比例
         * 1   :对齐模式
         */
        sendcommand("TEXT 10,150,\"2\",0,1,1,\"123456ABCD\"");
        sendcommand("BARCODE 100,250, \"128\",70,1,0,2,2, \"123456\"");
        /* QRCODE QRCODE左上角X坐标,QRCODE左上角Y坐标,纠错等级,宽度(1~10),模式,角度,条码对齐位置,版本,掩码,最大尺寸,数据内容 */
        sendcommand("QRCODE 90,40,H,5,A,0,M2,S7, \"12345ABCED\"");
        sendcommand("PRINT 1");
        closeport();

   }


       //hdll.unload();
}



四、常见问题

1、添加的动态库无法使用
答:根据自己的型号去官网下载正确的dll;
2、打印中文乱码问题
答:正确设置编码类型;

五、效果

TTP-244 Pro打印机

中文测试

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值