qt自定義的串口類判斷斷開

QObject::connect: Cannot queue arguments of type 'QSerialPort::SerialPortError'

(Make sure 'QSerialPort::SerialPortError' is registered using qRegisterMetaType().)

 

源代碼如下:

    connect(serial, SIGNAL(errorOccurred(QSerialPort::SerialPortError)),
            this, SLOT(deal_with_error(QSerialPort::SerialPortError)), Qt::QueuedConnection);

 

參考解決方法:

https://blog.csdn.net/weixin_43387612/article/details/108170747

 

在源代碼前加入如下一句:

qRegisterMetaType<QSerialPort::SerialPortError>("SerialThread");

問題解決.

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章