c++ - QWinEventNotifier : Can only be used with threads started with QThread

标签 c++ qt usb dongle qextserialport

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

我的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

这显示了端口号 Open,但是那条消息呢?这是否意味着我无法继续使用其他代码?在编写其他代码之前,我想知道这一点。

最佳答案

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

int main()
{
    QApplication app;

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

    system("pause");

    return app.exec();
}

关于c++ - QWinEventNotifier : Can only be used with threads started with QThread,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16394948/

相关文章:

c++ - 我可以在枚举中放置一个转换运算符以将其转换为不同的类型吗?

java - 需要使用 TCP 和 OpenSSL 将 Java 客户端连接到 Cpp 服务器

c++ - 如何使用 C++ win32 API 将 Variant Safe Array 转换为 Char?

c++ - QT中如何将带逗号的字符串转换为 float ?

c++ - 是否可以使用在 Windows 10 上运行的 Qt 5.12 构建针对 Windows XP 的 Qt 应用程序?

java - android中USB多播的问题

python - 将 libusb 代码移植到 Python : interrupt transfer

c++ - 如何使用 glibc 的字符串实现在堆栈上分配 std::string?

android - 在 Android 中查找 USB 设备

c# - QT 中字节数组到 double 转换失败