C++ QWinEventNotifier:只能与以QThread启动的线程一起使用
我正在尝试使用“QextSerialPort”打开我的Huwawei USB加密狗 我的端口详细信息如下C++ QWinEventNotifier:只能与以QThread启动的线程一起使用,c++,qt,usb,dongle,qextserialport,C++,Qt,Usb,Dongle,Qextserialport,我正在尝试使用“QextSerialPort”打开我的Huwawei USB加密狗 我的端口详细信息如下 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 I
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;
}
这显示端口id已打开,但该消息如何?这是否意味着我不能继续使用其他代码?我想在编写其他代码之前知道这一点 最有可能的情况是,您需要创建一个
QApplication
,如果没有它,许多事情(如事件和信号/插槽)将无法工作:
int main()
{
QApplication app;
QextSerialPort *port = new QextSerialPort("COM7");
port->open(QIODevice::ReadWrite);
cout << port->isOpen();
system("pause");
return app.exec();
}
intmain()
{
QApplication应用程序;
QextSerialPort*端口=新的QextSerialPort(“COM7”);
端口->打开(QIODevice::ReadWrite);
cout-isOpen();
系统(“暂停”);
返回app.exec();
}
最有可能的情况是,您需要创建一个QApplication
,如果没有它,许多事情(如事件和信号/插槽)将无法工作:
int main()
{
QApplication app;
QextSerialPort *port = new QextSerialPort("COM7");
port->open(QIODevice::ReadWrite);
cout << port->isOpen();
system("pause");
return app.exec();
}
intmain()
{
QApplication应用程序;
QextSerialPort*端口=新的QextSerialPort(“COM7”);
端口->打开(QIODevice::ReadWrite);
cout-isOpen();
系统(“暂停”);
返回app.exec();
}
我呼叫的端口是否正确?我对QT和USB编程非常陌生。顺便说一句,为什么不使用QtSerialPort(官方的Qt5附加组件)呢?还有,我是在呼叫正确的端口吗?我对QT和USB编程非常陌生,“不使用QtSerialPort(官方Qt5附加组件)的任何原因,顺便说一句,我需要更快地键入:PThanks以获得回复。但是我应该导入哪个头文件?我找不到“qapplication.h”,如果您没有创建GUI应用程序,请使用instead@Yohan,#include
应该可以。如果没有,请按照thuga的建议尝试#包括。谢谢我必须使用QCoreApplication头来实现它。无论如何,即使在GUI中,我也找不到ha,我需要更快地键入:PThanks以获得回复。但是我应该导入哪个头文件?我找不到“qapplication.h”,如果您没有创建GUI应用程序,请使用instead@Yohan,#include
应该可以。如果没有,请按照thuga的建议尝试#包括。谢谢我必须使用QCoreApplication头来实现它。无论如何,即使在GUI中,我也找不到