#ifndef APPSERIAL_H #define APPSERIAL_H /**/ #include #include #include class QSerialPort; class AppSerial : public QObject, public QAbstractNativeEventFilter { Q_OBJECT public: explicit AppSerial(QObject *parent = nullptr); ~AppSerial(); public: QSerialPort *m_SerialPort; private: static AppSerial* m_comChange; HWND m_hwnd; enum DataType{ TypeRecvData, TypeSendData }; public: // static Serial* getInstance(); static QStringList getAvailablePort(); void setHWND(HWND hwnd); protected: bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result); signals: /** * @brief 传出串口热插拔状态 * @param name 串口名 * @param flag true:插入 false:拔出 */ void comChangeStatus(QString name, bool flag); void sig_RecvSerialData(QByteArray recvData, int dataType); public slots: void slot_RecvSerialData(); void slot_SendSerialData(const QByteArray &sendData); }; #endif // APPSERIAL_H