⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 comtest.h

📁 在linux下的QT中使用串口的编程方法
💻 H
字号:
#include<QThread>
#include<QTextEdit>
#include<QMutex>
#include<QObject>
#include <QtGui/QLabel>
#include "win_qextserialport.h"
class comtest:public QThread
{
    Q_OBJECT
	public:
	QMutex *m;
	Win_QextSerialPort *port;
        comtest(Win_QextSerialPort *port)
	{
          		this->port=port;
          		m=new QMutex;
        }
          void run()
	        {
	                   char buff[1024];
                           int numBytes;
                           qDebug("thread2 is running!\n");
	              while(1)
	              {

                           this->msleep(100);
                           numBytes = port->bytesAvailable();
                            if(numBytes >0 )
                            {
                               m->lock();
                               emit readsignal();
                               m->unlock();
                             }
                       }
                  }
    signals:
                void readsignal();


};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -