0

我正在尝试使用“QextSerialPort”打开我的 Huwawei USB 加密狗。

我的 PORT 详细信息如下

Port Name:
Product ID:
Physical Name: \Device\000000ca
Vendor Id:
Friend Name:  SB

Port Name:
Product ID:?
Physical Name: \Device\USBPDO-10
Vendor Id: ?
Friend Name:  TH

Port Name: COM3
Product ID:
Physical Name: \Device\BthModem0
Vendor Id:
Friend Name: Standard Serial over Bluetooth link (COM3)

Port Name: COM4
Product ID:
Physical Name: \Device\BthModem2
Vendor Id:
Friend Name: Standard Serial over Bluetooth link (COM4)

Port Name: COM5
Product ID:
Physical Name: \Device\BthModem1
Vendor Id:
Friend Name: Standard Modem over Bluetooth link

Port Name: COM6
Product ID:?
Physical Name: \Device\000000e2
Vendor Id: ?
Friend Name: HUAWEI Mobile Connect - 3G Application Interface (COM6)

Port Name: COM7
Product ID:?
Physical Name: \Device\000000e0
Vendor Id: ?
Friend Name: HUAWEI Mobile Connect - 3G Modem

Port Name: COM8
Product ID:?
Physical Name: \Device\000000e3
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,但是那条消息呢?这是否意味着我不能继续使用其他代码?在编写其他代码之前,我想知道这一点。

4

1 回答 1

3

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

int main()
{
    QApplication app;

    QextSerialPort *port = new QextSerialPort("COM7");
    port->open(QIODevice::ReadWrite);
    cout << port->isOpen();

    system("pause");

    return app.exec();
}
于 2013-05-06T08:49:25.847 回答