m_edit = new QTextBrowser ( this );
m_comm = new Win_QextSerialPort("com2", QextSerialBase::EventDriven ); //定义串口控件
m_comm->open(QIODevice::ReadWrite ); //打开串口
m_comm->setBaudRate(BAUD9600 );
m_comm->setDataBits( DATA_8 );
m_comm->setParity( PAR_NONE );
m_comm->setStopBits( STOP_1 );
m_comm->setFlowControl(FLOW_OFF);
m_comm->setTimeout(500);
}
MyCom::~MyCom()
{
}
void MyCom::readCommon()
{
QByteArray ba = m_comm->readAll();
m_edit->insertPlainText( ba );
}
m_comm = new Win_QextSerialPort("com2", QextSerialBase::EventDriven ); //定义串口控件
m_comm->open(QIODevice::ReadWrite ); //打开串口
m_comm->setBaudRate(BAUD9600 );
m_comm->setDataBits( DATA_8 );
m_comm->setParity( PAR_NONE );
m_comm->setStopBits( STOP_1 );
m_comm->setFlowControl(FLOW_OFF);
m_comm->setTimeout(500);
注:此处需要先打开串口后再设置,要不然没有用
connect( m_comm, SIGNAL(readyRead()), this, SLOT(readCommon()));}
MyCom::~MyCom()
{
}
void MyCom::readCommon()
{
QByteArray ba = m_comm->readAll();
m_edit->insertPlainText( ba );
}