summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/enumerator/enumerator.pro8
-rw-r--r--examples/enumerator/main.cpp39
-rw-r--r--examples/examples.pro2
3 files changed, 48 insertions, 1 deletions
diff --git a/examples/enumerator/enumerator.pro b/examples/enumerator/enumerator.pro
new file mode 100644
index 00000000..a6e1d8d2
--- /dev/null
+++ b/examples/enumerator/enumerator.pro
@@ -0,0 +1,8 @@
+QT += widgets serialport
+
+TARGET = enumerator
+TEMPLATE = app
+
+
+SOURCES += \
+ main.cpp \ No newline at end of file
diff --git a/examples/enumerator/main.cpp b/examples/enumerator/main.cpp
new file mode 100644
index 00000000..2d737fad
--- /dev/null
+++ b/examples/enumerator/main.cpp
@@ -0,0 +1,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();
+}
diff --git a/examples/examples.pro b/examples/examples.pro
index 9a207e52..33716ef4 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -1,3 +1,3 @@
TEMPLATE = subdirs
CONFIG += ordered
-SUBDIRS = terminal
+SUBDIRS = terminal enumerator