#include "posdevice.h" PosDevice::PosDevice(QObject *parent) : QObject{parent} { serialHandler = new QSerialPort(this); serialHandler->setPortName(COMNAME); serialHandler->setBaudRate(460800); } bool PosDevice::open(){ bool bState = false; if(serialHandler->open(QIODevice::ReadWrite)){ bState = true; } connect(serialHandler,&QSerialPort::readyRead,this,&PosDevice::readData); return bState; } void PosDevice::close(){ disconnect(serialHandler,&QSerialPort::readyRead,this,&PosDevice::readData); serialHandler->close(); } void PosDevice::readData(){ QByteArray datatmp = serialHandler->readAll(); if(!datatmp.isEmpty()){ QString data = QString::fromUtf8(datatmp); QVector posdata; // qDebug()<