blob: 2d737fadc9ad6e0f97e3a8d25f2931ff8df9a7b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#include <QtWidgets/QApplication>
#include <QtWidgets/QWidget>
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QLabel>
#include <QtAddOnSerialPort/serialportinfo.h>
QT_USE_NAMESPACE_SERIALPORT
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget w;
w.setWindowTitle(QObject::tr("Info about all available serial ports."));
QVBoxLayout *layout = new QVBoxLayout;
foreach (const SerialPortInfo &info, SerialPortInfo::availablePorts()) {
QString s(QObject::tr("Port: %1\n"
"Location: %2\n"
"Description: %3\n"
"Manufacturer: %4\n"
"Vid: %5\n"
"Pid: %6\n"
"Busy: %7\n"));
s = s.arg(info.portName()).arg(info.systemLocation())
.arg(info.description()).arg(info.manufacturer())
.arg(info.vid()).arg(info.pid())
.arg(info.isBusy() ? QObject::tr("Yes") : QObject::tr("No"));
QLabel *label = new QLabel(s);
layout->addWidget(label);
}
w.setLayout(layout);
w.show();
return a.exec();
}
|