这是我的代码:
#include "MyClass.h"
#include <qstring.h>
#include <qdebug.h>
MyClass::MyClass()
{
QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
int counter=0;
while(counter<ports.size())
{
QString portName = ports[counter].portName;
QString productId= ports[counter].productID;
QString physicalName = ports[counter].physName;
QString vendorId = ports[counter].vendorID;
QString friendName = ports[counter].friendName;
string convertedPortName = portName.toLocal8Bit().constData();
string convertedProductId = productId.toLocal8Bit().constData();
string convertedPhysicalName = physicalName.toLocal8Bit().constData();
string convertedVendorId = vendorId.toLocal8Bit().constData();
string convertedFriendName = friendName.toLocal8Bit().constData();
cout << "Port Name: " << convertedPortName << endl;
cout << "Product ID:" << convertedProductId << endl;
cout << "Physical Name: " << convertedPhysicalName << endl;
cout << "Vendor Id: " << convertedVendorId << endl;
cout << "Friend Name: " << convertedFriendName << endl;
cout << endl;
counter++;
}
}
我已经连接了“Dreamcheeky Thunder Missile Launcher”USB 玩具,但我无法获得它的供应商 ID 或产品 ID 或至少任何与之相关的信息!见下图
但是使用 USBDView 软件,我可以得到所有的细节。见下图
我的代码有什么问题?或者如果它根本不适合?