#ifndef CGPSTERMINAL_H #define CGPSTERMINAL_H //------------------------------------ #include <QMainWindow> #include <QtSerialPort/QSerialPort> #include <QtSerialPort/QSerialPortInfo> #include <QtDebug> //------------------- namespace Ui { class CGPSTerminal; } //-------------------------------------------------------------- class CGPSTerminal : public QMainWindow { Q_OBJECT public: explicit CGPSTerminal(QWidget *parent = 0); ~CGPSTerminal(); private: Ui::CGPSTerminal *m_ui; QSerialPort *m_port; };#endif // CGPSTERMINAL_H
#include "cgpsterminal.h"#include "ui_cgpsterminal.h"//---------------------------------------------------------------------------------------------------------------------------------------------------CGPSTerminal::CGPSTerminal(QWidget *parent) : QMainWindow(parent), m_ui(new Ui::CGPSTerminal){ m_ui->setupUi(this); m_port = new QSerialPort(); m_port->setPortName(tr("COM3")); if(m_port->open(QIODevice::ReadWrite | QIODevice::WriteOnly)) qDebug() << "Port is open"; else qDebug() << "Port is not open";}//-----------------------------------------------CGPSTerminal::~CGPSTerminal(){ delete m_ui;}