summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorDenis Shienkov <scapig@yandex.ru>2012-03-31 23:28:48 +0400
committerDenis Shienkov <scapig@yandex.ru>2012-04-01 17:04:15 +0200
commit5a9fc73a2569f2d52119f08a20f35ec343a75753 (patch)
tree3ad1be68e8c0a03add72d165a38053d414e25019 /examples
parent8038195bbf30f7a3f5c6f639f183e5a3aadd5372 (diff)
Added an enumerator example.
Change-Id: If88a0a300bcd011489be462536fadadf16da6171 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <scapig@yandex.ru>
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