summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2014-12-01 14:30:57 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2014-12-01 16:51:48 +0100
commit383ee53814649190e24e08a16acd6aee629de157 (patch)
tree6e6c45713560ae27838100cb601bd99d89eb688f /examples
parent28aca3ba21f855e2fea38c050e9a4fd35d620d7b (diff)
downloadqtserialport-383ee53814649190e24e08a16acd6aee629de157.tar.gz
Add scroll area to Enumerator example
When a system has many serial ports, the last of them are not visible on the screen, because a widget has a big height. So, it is reasonable to add scrolling of all serial ports info. Change-Id: Ic13b58fba38a17d6f5142476bca501a0d26ec76d Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/serialport/enumerator/main.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/examples/serialport/enumerator/main.cpp b/examples/serialport/enumerator/main.cpp
index 007e918..40bc67a 100644
--- a/examples/serialport/enumerator/main.cpp
+++ b/examples/serialport/enumerator/main.cpp
@@ -36,6 +36,7 @@
#include <QWidget>
#include <QVBoxLayout>
#include <QLabel>
+#include <QScrollArea>
#include <QtSerialPort/QSerialPortInfo>
QT_USE_NAMESPACE
@@ -44,8 +45,6 @@ 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 QSerialPortInfo &info, QSerialPortInfo::availablePorts()) {
@@ -62,8 +61,13 @@ int main(int argc, char *argv[])
layout->addWidget(label);
}
- w.setLayout(layout);
- w.show();
+ QWidget *workPage = new QWidget;
+ workPage->setLayout(layout);
+
+ QScrollArea area;
+ area.setWindowTitle(QObject::tr("Info about all available serial ports."));
+ area.setWidget(workPage);
+ area.show();
return a.exec();
}