代码拉取完成,页面将自动刷新
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "winusbdriver.h"
WinUSBDriver winusb;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->setWindowTitle("WINUSB测试");
connect(&winusb,SIGNAL(recvSignals(unsigned char *,int)),this,SLOT(usbRecvSlot(unsigned char *,int)));
connect(&winusb,SIGNAL(disconnectSignals()),this,SLOT(disconnectSlot()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::usbRecvSlot(unsigned char *buf,int len)
{
buf[len] = '\0';
//DBG("recv:%s",buf);
QString qstr = QString(QLatin1String((const char*)buf));
ui->te_recv->append(qstr);
ui->te_recv->moveCursor(QTextCursor::End);
}
void MainWindow::on_pb_open_clicked()
{
if(ui->pb_open->text().compare(QString::fromUtf8("打开")) == 0)
{
int vid = ui->le_vid->text().toInt();
int pid = ui->le_pid->text().toInt();
if(winusb.open(vid,pid) == 0)
{
ui->pb_open->setText("关闭");
}
}else
{
winusb.close();
ui->pb_open->setText("打开");
}
}
void MainWindow::disconnectSlot(void)
{
winusb.close();
ui->pb_open->setText("打开");
}
void MainWindow::on_pb_send_clicked()
{
QByteArray bytes = ui->le_send->text().toUtf8();
winusb.send(bytes);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。