Answer the question
In order to leave comments, you need to log in
Why doesn't foreach work in C++ Qt?
Hello everyone)
There is a ready class QSerialDevice
There is an example Enumerator (a list of available COM ports)
foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts()) {
QString s = QObject::tr("Port: ") + info.portName() + "\n"
+ QObject::tr("Location: ") + info.systemLocation() + "\n"
+ QObject::tr("Description: ") + info.description() + "\n"
+ QObject::tr("Manufacturer: ") + info.manufacturer() + "\n"
+ QObject::tr("Serial number: ") + info.serialNumber() + "\n"
+ QObject::tr("Vendor Identifier: ") + (info.hasVendorIdentifier() ? QString::number(info.vendorIdentifier(), 16) : QString()) + "\n"
+ QObject::tr("Product Identifier: ") + (info.hasProductIdentifier() ? QString::number(info.productIdentifier(), 16) : QString()) + "\n"
+ QObject::tr("Busy: ") + (info.isBusy() ? QObject::tr("Yes") : QObject::tr("No")) + "\n";
}
Answer the question
In order to leave comments, you need to log in
CONFIG += c++14
to a .pro file for qmake. This will include all chips of the 14th standard. By default, you may well have the C ++ 97 standard.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question