QWinEventNotifier:只能用于以QThread启动的线程



我正在尝试使用"QextSerialPort"打开我的华为USB加密狗。

我的PORT详细信息如下

Port Name:
Product ID:
Physical Name: Device00000ca
Vendor Id:
Friend Name:  SB
Port Name:
Product ID:?
Physical Name: DeviceUSBPDO-10
Vendor Id: ?
Friend Name:  TH
Port Name: COM3
Product ID:
Physical Name: DeviceBthModem0
Vendor Id:
Friend Name: Standard Serial over Bluetooth link (COM3)
Port Name: COM4
Product ID:
Physical Name: DeviceBthModem2
Vendor Id:
Friend Name: Standard Serial over Bluetooth link (COM4)
Port Name: COM5
Product ID:
Physical Name: DeviceBthModem1
Vendor Id:
Friend Name: Standard Modem over Bluetooth link
Port Name: COM6
Product ID:?
Physical Name: Device00000e2
Vendor Id: ?
Friend Name: HUAWEI Mobile Connect - 3G Application Interface (COM6)
Port Name: COM7
Product ID:?
Physical Name: Device00000e0
Vendor Id: ?
Friend Name: HUAWEI Mobile Connect - 3G Modem
Port Name: COM8
Product ID:?
Physical Name: Device00000e3
Vendor Id: ?
Friend Name: HUAWEI Mobile Connect - 3G PC UI Interface (COM8)

我试图打开我的USB加密狗,所以我可以发送短信。下面是我打开

的代码
#include "MyClass.h"
#include <qstring.h>
#include <qdebug.h>

int main()
{
    QextSerialPort *port = new QextSerialPort("COM7");
    port->open(QIODevice::ReadWrite);
    cout << port->isOpen();
    system("pause");
    return 0;
}

当我运行这段代码时,我得到的是

QWinEventNotifier: Can only be used with threads started with QThread 
1

显示了端口id Open,但是该消息是什么呢?这是否意味着我不能继续执行其他代码?在我编写其他代码之前,我想知道这一点。

最有可能的是,你需要创建一个QApplication,没有它,许多事情,如事件和信号/插槽将无法工作:

int main()
{
    QApplication app;
    QextSerialPort *port = new QextSerialPort("COM7");
    port->open(QIODevice::ReadWrite);
    cout << port->isOpen();
    system("pause");
    return app.exec();
}

相关内容

  • 没有找到相关文章

最新更新