summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2017-09-27 15:23:37 (GMT)
committerDenis Shienkov <denis.shienkov@gmail.com>2017-10-05 06:17:20 (GMT)
commit60efa7c9a2d393d5c7e48f1e0dcb26b6effa4e5d (patch)
treecae15e41ef05d423158926e615577d52e6f4db89
parent671233ea2b2f2903b153726f4d6358fb5673d279 (diff)
downloadqtserialport-60efa7c9a2d393d5c7e48f1e0dcb26b6effa4e5d.tar.gz
Revamp the Terminal Example
* Use the 'm_' prefixes for all class members. * Use the QOverload in signal/slot casting. * Use more member class initializations. * Remove QT_USE_NAMESPACE macro. Task-number: QTBUG-60652 Change-Id: I1a2000de2f9a5152de31ec896659b6721aeb3a9a Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--examples/serialport/terminal/console.cpp8
-rw-r--r--examples/serialport/terminal/console.h2
-rw-r--r--examples/serialport/terminal/main.cpp4
-rw-r--r--examples/serialport/terminal/mainwindow.cpp107
-rw-r--r--examples/serialport/terminal/mainwindow.h10
-rw-r--r--examples/serialport/terminal/settingsdialog.cpp147
-rw-r--r--examples/serialport/terminal/settingsdialog.h10
7 files changed, 141 insertions, 147 deletions
diff --git a/examples/serialport/terminal/console.cpp b/examples/serialport/terminal/console.cpp
index b0e9bcd..d71c5c0 100644
--- a/examples/serialport/terminal/console.cpp
+++ b/examples/serialport/terminal/console.cpp
@@ -53,8 +53,8 @@
#include <QScrollBar>
-Console::Console(QWidget *parent)
- : QPlainTextEdit(parent)
+Console::Console(QWidget *parent) :
+ QPlainTextEdit(parent)
{
document()->setMaximumBlockCount(100);
QPalette p = palette();
@@ -73,7 +73,7 @@ void Console::putData(const QByteArray &data)
void Console::setLocalEchoEnabled(bool set)
{
- localEchoEnabled = set;
+ m_localEchoEnabled = set;
}
void Console::keyPressEvent(QKeyEvent *e)
@@ -86,7 +86,7 @@ void Console::keyPressEvent(QKeyEvent *e)
case Qt::Key_Down:
break;
default:
- if (localEchoEnabled)
+ if (m_localEchoEnabled)
QPlainTextEdit::keyPressEvent(e);
emit getData(e->text().toLocal8Bit());
}
diff --git a/examples/serialport/terminal/console.h b/examples/serialport/terminal/console.h
index 0a5cd64..b9fe553 100644
--- a/examples/serialport/terminal/console.h
+++ b/examples/serialport/terminal/console.h
@@ -74,7 +74,7 @@ protected:
void contextMenuEvent(QContextMenuEvent *e) override;
private:
- bool localEchoEnabled = false;
+ bool m_localEchoEnabled = false;
};
#endif // CONSOLE_H
diff --git a/examples/serialport/terminal/main.cpp b/examples/serialport/terminal/main.cpp
index ec64e37..a6e901a 100644
--- a/examples/serialport/terminal/main.cpp
+++ b/examples/serialport/terminal/main.cpp
@@ -49,10 +49,10 @@
**
****************************************************************************/
-#include <QApplication>
-
#include "mainwindow.h"
+#include <QApplication>
+
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
diff --git a/examples/serialport/terminal/mainwindow.cpp b/examples/serialport/terminal/mainwindow.cpp
index f4589bb..e8ac9d7 100644
--- a/examples/serialport/terminal/mainwindow.cpp
+++ b/examples/serialport/terminal/mainwindow.cpp
@@ -54,72 +54,71 @@
#include "console.h"
#include "settingsdialog.h"
-#include <QMessageBox>
#include <QLabel>
+#include <QMessageBox>
//! [0]
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
- ui(new Ui::MainWindow)
-{
-//! [0]
- ui->setupUi(this);
- console = new Console;
- console->setEnabled(false);
- setCentralWidget(console);
+ m_ui(new Ui::MainWindow),
+ m_status(new QLabel),
+ m_console(new Console),
+ m_settings(new SettingsDialog),
//! [1]
- serial = new QSerialPort(this);
+ m_serial(new QSerialPort(this))
//! [1]
- settings = new SettingsDialog;
+{
+//! [0]
+ m_ui->setupUi(this);
+ m_console->setEnabled(false);
+ setCentralWidget(m_console);
- ui->actionConnect->setEnabled(true);
- ui->actionDisconnect->setEnabled(false);
- ui->actionQuit->setEnabled(true);
- ui->actionConfigure->setEnabled(true);
+ m_ui->actionConnect->setEnabled(true);
+ m_ui->actionDisconnect->setEnabled(false);
+ m_ui->actionQuit->setEnabled(true);
+ m_ui->actionConfigure->setEnabled(true);
- status = new QLabel;
- ui->statusBar->addWidget(status);
+ m_ui->statusBar->addWidget(m_status);
initActionsConnections();
- connect(serial, static_cast<void (QSerialPort::*)(QSerialPort::SerialPortError)>(&QSerialPort::error),
- this, &MainWindow::handleError);
+ connect(m_serial, &QSerialPort::errorOccurred, this, &MainWindow::handleError);
//! [2]
- connect(serial, &QSerialPort::readyRead, this, &MainWindow::readData);
+ connect(m_serial, &QSerialPort::readyRead, this, &MainWindow::readData);
//! [2]
- connect(console, &Console::getData, this, &MainWindow::writeData);
+ connect(m_console, &Console::getData, this, &MainWindow::writeData);
//! [3]
}
//! [3]
MainWindow::~MainWindow()
{
- delete settings;
- delete ui;
+ delete m_settings;
+ delete m_ui;
}
//! [4]
void MainWindow::openSerialPort()
{
- SettingsDialog::Settings p = settings->settings();
- serial->setPortName(p.name);
- serial->setBaudRate(p.baudRate);
- serial->setDataBits(p.dataBits);
- serial->setParity(p.parity);
- serial->setStopBits(p.stopBits);
- serial->setFlowControl(p.flowControl);
- if (serial->open(QIODevice::ReadWrite)) {
- console->setEnabled(true);
- console->setLocalEchoEnabled(p.localEchoEnabled);
- ui->actionConnect->setEnabled(false);
- ui->actionDisconnect->setEnabled(true);
- ui->actionConfigure->setEnabled(false);
+ const SettingsDialog::Settings p = m_settings->settings();
+ m_serial->setPortName(p.name);
+ m_serial->setBaudRate(p.baudRate);
+ m_serial->setDataBits(p.dataBits);
+ m_serial->setParity(p.parity);
+ m_serial->setStopBits(p.stopBits);
+ m_serial->setFlowControl(p.flowControl);
+ if (m_serial->open(QIODevice::ReadWrite)) {
+ m_console->setEnabled(true);
+ m_console->setLocalEchoEnabled(p.localEchoEnabled);
+ m_ui->actionConnect->setEnabled(false);
+ m_ui->actionDisconnect->setEnabled(true);
+ m_ui->actionConfigure->setEnabled(false);
showStatusMessage(tr("Connected to %1 : %2, %3, %4, %5, %6")
.arg(p.name).arg(p.stringBaudRate).arg(p.stringDataBits)
.arg(p.stringParity).arg(p.stringStopBits).arg(p.stringFlowControl));
} else {
- QMessageBox::critical(this, tr("Error"), serial->errorString());
+ QMessageBox::critical(this, tr("Error"), m_serial->errorString());
showStatusMessage(tr("Open error"));
}
@@ -129,12 +128,12 @@ void MainWindow::openSerialPort()
//! [5]
void MainWindow::closeSerialPort()
{
- if (serial->isOpen())
- serial->close();
- console->setEnabled(false);
- ui->actionConnect->setEnabled(true);
- ui->actionDisconnect->setEnabled(false);
- ui->actionConfigure->setEnabled(true);
+ if (m_serial->isOpen())
+ m_serial->close();
+ m_console->setEnabled(false);
+ m_ui->actionConnect->setEnabled(true);
+ m_ui->actionDisconnect->setEnabled(false);
+ m_ui->actionConfigure->setEnabled(true);
showStatusMessage(tr("Disconnected"));
}
//! [5]
@@ -150,15 +149,15 @@ void MainWindow::about()
//! [6]
void MainWindow::writeData(const QByteArray &data)
{
- serial->write(data);
+ m_serial->write(data);
}
//! [6]
//! [7]
void MainWindow::readData()
{
- QByteArray data = serial->readAll();
- console->putData(data);
+ const QByteArray data = m_serial->readAll();
+ m_console->putData(data);
}
//! [7]
@@ -166,7 +165,7 @@ void MainWindow::readData()
void MainWindow::handleError(QSerialPort::SerialPortError error)
{
if (error == QSerialPort::ResourceError) {
- QMessageBox::critical(this, tr("Critical Error"), serial->errorString());
+ QMessageBox::critical(this, tr("Critical Error"), m_serial->errorString());
closeSerialPort();
}
}
@@ -174,16 +173,16 @@ void MainWindow::handleError(QSerialPort::SerialPortError error)
void MainWindow::initActionsConnections()
{
- connect(ui->actionConnect, &QAction::triggered, this, &MainWindow::openSerialPort);
- connect(ui->actionDisconnect, &QAction::triggered, this, &MainWindow::closeSerialPort);
- connect(ui->actionQuit, &QAction::triggered, this, &MainWindow::close);
- connect(ui->actionConfigure, &QAction::triggered, settings, &SettingsDialog::show);
- connect(ui->actionClear, &QAction::triggered, console, &Console::clear);
- connect(ui->actionAbout, &QAction::triggered, this, &MainWindow::about);
- connect(ui->actionAboutQt, &QAction::triggered, qApp, &QApplication::aboutQt);
+ connect(m_ui->actionConnect, &QAction::triggered, this, &MainWindow::openSerialPort);
+ connect(m_ui->actionDisconnect, &QAction::triggered, this, &MainWindow::closeSerialPort);
+ connect(m_ui->actionQuit, &QAction::triggered, this, &MainWindow::close);
+ connect(m_ui->actionConfigure, &QAction::triggered, m_settings, &SettingsDialog::show);
+ connect(m_ui->actionClear, &QAction::triggered, m_console, &Console::clear);
+ connect(m_ui->actionAbout, &QAction::triggered, this, &MainWindow::about);
+ connect(m_ui->actionAboutQt, &QAction::triggered, qApp, &QApplication::aboutQt);
}
void MainWindow::showStatusMessage(const QString &message)
{
- status->setText(message);
+ m_status->setText(message);
}
diff --git a/examples/serialport/terminal/mainwindow.h b/examples/serialport/terminal/mainwindow.h
index 31b724b..eebae8c 100644
--- a/examples/serialport/terminal/mainwindow.h
+++ b/examples/serialport/terminal/mainwindow.h
@@ -91,11 +91,11 @@ private:
private:
void showStatusMessage(const QString &message);
- Ui::MainWindow *ui = nullptr;
- QLabel *status = nullptr;
- Console *console = nullptr;
- SettingsDialog *settings = nullptr;
- QSerialPort *serial = nullptr;
+ Ui::MainWindow *m_ui = nullptr;
+ QLabel *m_status = nullptr;
+ Console *m_console = nullptr;
+ SettingsDialog *m_settings = nullptr;
+ QSerialPort *m_serial = nullptr;
};
#endif // MAINWINDOW_H
diff --git a/examples/serialport/terminal/settingsdialog.cpp b/examples/serialport/terminal/settingsdialog.cpp
index f9b8605..4b16bf5 100644
--- a/examples/serialport/terminal/settingsdialog.cpp
+++ b/examples/serialport/terminal/settingsdialog.cpp
@@ -52,31 +52,28 @@
#include "settingsdialog.h"
#include "ui_settingsdialog.h"
-#include <QtSerialPort/QSerialPortInfo>
#include <QIntValidator>
#include <QLineEdit>
-
-QT_USE_NAMESPACE
+#include <QSerialPortInfo>
static const char blankString[] = QT_TRANSLATE_NOOP("SettingsDialog", "N/A");
SettingsDialog::SettingsDialog(QWidget *parent) :
QDialog(parent),
- ui(new Ui::SettingsDialog)
+ m_ui(new Ui::SettingsDialog),
+ m_intValidator(new QIntValidator(0, 4000000, this))
{
- ui->setupUi(this);
-
- intValidator = new QIntValidator(0, 4000000, this);
+ m_ui->setupUi(this);
- ui->baudRateBox->setInsertPolicy(QComboBox::NoInsert);
+ m_ui->baudRateBox->setInsertPolicy(QComboBox::NoInsert);
- connect(ui->applyButton, &QPushButton::clicked,
+ connect(m_ui->applyButton, &QPushButton::clicked,
this, &SettingsDialog::apply);
- connect(ui->serialPortInfoListBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
+ connect(m_ui->serialPortInfoListBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &SettingsDialog::showPortInfo);
- connect(ui->baudRateBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
+ connect(m_ui->baudRateBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &SettingsDialog::checkCustomBaudRatePolicy);
- connect(ui->serialPortInfoListBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
+ connect(m_ui->serialPortInfoListBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &SettingsDialog::checkCustomDevicePathPolicy);
fillPortsParameters();
@@ -87,12 +84,12 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
SettingsDialog::~SettingsDialog()
{
- delete ui;
+ delete m_ui;
}
SettingsDialog::Settings SettingsDialog::settings() const
{
- return currentSettings;
+ return m_currentSettings;
}
void SettingsDialog::showPortInfo(int idx)
@@ -100,13 +97,13 @@ void SettingsDialog::showPortInfo(int idx)
if (idx == -1)
return;
- QStringList list = ui->serialPortInfoListBox->itemData(idx).toStringList();
- ui->descriptionLabel->setText(tr("Description: %1").arg(list.count() > 1 ? list.at(1) : tr(blankString)));
- ui->manufacturerLabel->setText(tr("Manufacturer: %1").arg(list.count() > 2 ? list.at(2) : tr(blankString)));
- ui->serialNumberLabel->setText(tr("Serial number: %1").arg(list.count() > 3 ? list.at(3) : tr(blankString)));
- ui->locationLabel->setText(tr("Location: %1").arg(list.count() > 4 ? list.at(4) : tr(blankString)));
- ui->vidLabel->setText(tr("Vendor Identifier: %1").arg(list.count() > 5 ? list.at(5) : tr(blankString)));
- ui->pidLabel->setText(tr("Product Identifier: %1").arg(list.count() > 6 ? list.at(6) : tr(blankString)));
+ const QStringList list = m_ui->serialPortInfoListBox->itemData(idx).toStringList();
+ m_ui->descriptionLabel->setText(tr("Description: %1").arg(list.count() > 1 ? list.at(1) : tr(blankString)));
+ m_ui->manufacturerLabel->setText(tr("Manufacturer: %1").arg(list.count() > 2 ? list.at(2) : tr(blankString)));
+ m_ui->serialNumberLabel->setText(tr("Serial number: %1").arg(list.count() > 3 ? list.at(3) : tr(blankString)));
+ m_ui->locationLabel->setText(tr("Location: %1").arg(list.count() > 4 ? list.at(4) : tr(blankString)));
+ m_ui->vidLabel->setText(tr("Vendor Identifier: %1").arg(list.count() > 5 ? list.at(5) : tr(blankString)));
+ m_ui->pidLabel->setText(tr("Product Identifier: %1").arg(list.count() > 6 ? list.at(6) : tr(blankString)));
}
void SettingsDialog::apply()
@@ -117,57 +114,57 @@ void SettingsDialog::apply()
void SettingsDialog::checkCustomBaudRatePolicy(int idx)
{
- bool isCustomBaudRate = !ui->baudRateBox->itemData(idx).isValid();
- ui->baudRateBox->setEditable(isCustomBaudRate);
+ const bool isCustomBaudRate = !m_ui->baudRateBox->itemData(idx).isValid();
+ m_ui->baudRateBox->setEditable(isCustomBaudRate);
if (isCustomBaudRate) {
- ui->baudRateBox->clearEditText();
- QLineEdit *edit = ui->baudRateBox->lineEdit();
- edit->setValidator(intValidator);
+ m_ui->baudRateBox->clearEditText();
+ QLineEdit *edit = m_ui->baudRateBox->lineEdit();
+ edit->setValidator(m_intValidator);
}
}
void SettingsDialog::checkCustomDevicePathPolicy(int idx)
{
- bool isCustomPath = !ui->serialPortInfoListBox->itemData(idx).isValid();
- ui->serialPortInfoListBox->setEditable(isCustomPath);
+ const bool isCustomPath = !m_ui->serialPortInfoListBox->itemData(idx).isValid();
+ m_ui->serialPortInfoListBox->setEditable(isCustomPath);
if (isCustomPath)
- ui->serialPortInfoListBox->clearEditText();
+ m_ui->serialPortInfoListBox->clearEditText();
}
void SettingsDialog::fillPortsParameters()
{
- ui->baudRateBox->addItem(QStringLiteral("9600"), QSerialPort::Baud9600);
- ui->baudRateBox->addItem(QStringLiteral("19200"), QSerialPort::Baud19200);
- ui->baudRateBox->addItem(QStringLiteral("38400"), QSerialPort::Baud38400);
- ui->baudRateBox->addItem(QStringLiteral("115200"), QSerialPort::Baud115200);
- ui->baudRateBox->addItem(tr("Custom"));
-
- ui->dataBitsBox->addItem(QStringLiteral("5"), QSerialPort::Data5);
- ui->dataBitsBox->addItem(QStringLiteral("6"), QSerialPort::Data6);
- ui->dataBitsBox->addItem(QStringLiteral("7"), QSerialPort::Data7);
- ui->dataBitsBox->addItem(QStringLiteral("8"), QSerialPort::Data8);
- ui->dataBitsBox->setCurrentIndex(3);
-
- ui->parityBox->addItem(tr("None"), QSerialPort::NoParity);
- ui->parityBox->addItem(tr("Even"), QSerialPort::EvenParity);
- ui->parityBox->addItem(tr("Odd"), QSerialPort::OddParity);
- ui->parityBox->addItem(tr("Mark"), QSerialPort::MarkParity);
- ui->parityBox->addItem(tr("Space"), QSerialPort::SpaceParity);
-
- ui->stopBitsBox->addItem(QStringLiteral("1"), QSerialPort::OneStop);
+ m_ui->baudRateBox->addItem(QStringLiteral("9600"), QSerialPort::Baud9600);
+ m_ui->baudRateBox->addItem(QStringLiteral("19200"), QSerialPort::Baud19200);
+ m_ui->baudRateBox->addItem(QStringLiteral("38400"), QSerialPort::Baud38400);
+ m_ui->baudRateBox->addItem(QStringLiteral("115200"), QSerialPort::Baud115200);
+ m_ui->baudRateBox->addItem(tr("Custom"));
+
+ m_ui->dataBitsBox->addItem(QStringLiteral("5"), QSerialPort::Data5);
+ m_ui->dataBitsBox->addItem(QStringLiteral("6"), QSerialPort::Data6);
+ m_ui->dataBitsBox->addItem(QStringLiteral("7"), QSerialPort::Data7);
+ m_ui->dataBitsBox->addItem(QStringLiteral("8"), QSerialPort::Data8);
+ m_ui->dataBitsBox->setCurrentIndex(3);
+
+ m_ui->parityBox->addItem(tr("None"), QSerialPort::NoParity);
+ m_ui->parityBox->addItem(tr("Even"), QSerialPort::EvenParity);
+ m_ui->parityBox->addItem(tr("Odd"), QSerialPort::OddParity);
+ m_ui->parityBox->addItem(tr("Mark"), QSerialPort::MarkParity);
+ m_ui->parityBox->addItem(tr("Space"), QSerialPort::SpaceParity);
+
+ m_ui->stopBitsBox->addItem(QStringLiteral("1"), QSerialPort::OneStop);
#ifdef Q_OS_WIN
- ui->stopBitsBox->addItem(tr("1.5"), QSerialPort::OneAndHalfStop);
+ m_ui->stopBitsBox->addItem(tr("1.5"), QSerialPort::OneAndHalfStop);
#endif
- ui->stopBitsBox->addItem(QStringLiteral("2"), QSerialPort::TwoStop);
+ m_ui->stopBitsBox->addItem(QStringLiteral("2"), QSerialPort::TwoStop);
- ui->flowControlBox->addItem(tr("None"), QSerialPort::NoFlowControl);
- ui->flowControlBox->addItem(tr("RTS/CTS"), QSerialPort::HardwareControl);
- ui->flowControlBox->addItem(tr("XON/XOFF"), QSerialPort::SoftwareControl);
+ m_ui->flowControlBox->addItem(tr("None"), QSerialPort::NoFlowControl);
+ m_ui->flowControlBox->addItem(tr("RTS/CTS"), QSerialPort::HardwareControl);
+ m_ui->flowControlBox->addItem(tr("XON/XOFF"), QSerialPort::SoftwareControl);
}
void SettingsDialog::fillPortsInfo()
{
- ui->serialPortInfoListBox->clear();
+ m_ui->serialPortInfoListBox->clear();
QString description;
QString manufacturer;
QString serialNumber;
@@ -185,39 +182,39 @@ void SettingsDialog::fillPortsInfo()
<< (info.vendorIdentifier() ? QString::number(info.vendorIdentifier(), 16) : blankString)
<< (info.productIdentifier() ? QString::number(info.productIdentifier(), 16) : blankString);
- ui->serialPortInfoListBox->addItem(list.first(), list);
+ m_ui->serialPortInfoListBox->addItem(list.first(), list);
}
- ui->serialPortInfoListBox->addItem(tr("Custom"));
+ m_ui->serialPortInfoListBox->addItem(tr("Custom"));
}
void SettingsDialog::updateSettings()
{
- currentSettings.name = ui->serialPortInfoListBox->currentText();
+ m_currentSettings.name = m_ui->serialPortInfoListBox->currentText();
- if (ui->baudRateBox->currentIndex() == 4) {
- currentSettings.baudRate = ui->baudRateBox->currentText().toInt();
+ if (m_ui->baudRateBox->currentIndex() == 4) {
+ m_currentSettings.baudRate = m_ui->baudRateBox->currentText().toInt();
} else {
- currentSettings.baudRate = static_cast<QSerialPort::BaudRate>(
- ui->baudRateBox->itemData(ui->baudRateBox->currentIndex()).toInt());
+ m_currentSettings.baudRate = static_cast<QSerialPort::BaudRate>(
+ m_ui->baudRateBox->itemData(m_ui->baudRateBox->currentIndex()).toInt());
}
- currentSettings.stringBaudRate = QString::number(currentSettings.baudRate);
+ m_currentSettings.stringBaudRate = QString::number(m_currentSettings.baudRate);
- currentSettings.dataBits = static_cast<QSerialPort::DataBits>(
- ui->dataBitsBox->itemData(ui->dataBitsBox->currentIndex()).toInt());
- currentSettings.stringDataBits = ui->dataBitsBox->currentText();
+ m_currentSettings.dataBits = static_cast<QSerialPort::DataBits>(
+ m_ui->dataBitsBox->itemData(m_ui->dataBitsBox->currentIndex()).toInt());
+ m_currentSettings.stringDataBits = m_ui->dataBitsBox->currentText();
- currentSettings.parity = static_cast<QSerialPort::Parity>(
- ui->parityBox->itemData(ui->parityBox->currentIndex()).toInt());
- currentSettings.stringParity = ui->parityBox->currentText();
+ m_currentSettings.parity = static_cast<QSerialPort::Parity>(
+ m_ui->parityBox->itemData(m_ui->parityBox->currentIndex()).toInt());
+ m_currentSettings.stringParity = m_ui->parityBox->currentText();
- currentSettings.stopBits = static_cast<QSerialPort::StopBits>(
- ui->stopBitsBox->itemData(ui->stopBitsBox->currentIndex()).toInt());
- currentSettings.stringStopBits = ui->stopBitsBox->currentText();
+ m_currentSettings.stopBits = static_cast<QSerialPort::StopBits>(
+ m_ui->stopBitsBox->itemData(m_ui->stopBitsBox->currentIndex()).toInt());
+ m_currentSettings.stringStopBits = m_ui->stopBitsBox->currentText();
- currentSettings.flowControl = static_cast<QSerialPort::FlowControl>(
- ui->flowControlBox->itemData(ui->flowControlBox->currentIndex()).toInt());
- currentSettings.stringFlowControl = ui->flowControlBox->currentText();
+ m_currentSettings.flowControl = static_cast<QSerialPort::FlowControl>(
+ m_ui->flowControlBox->itemData(m_ui->flowControlBox->currentIndex()).toInt());
+ m_currentSettings.stringFlowControl = m_ui->flowControlBox->currentText();
- currentSettings.localEchoEnabled = ui->localEchoCheckBox->isChecked();
+ m_currentSettings.localEchoEnabled = m_ui->localEchoCheckBox->isChecked();
}
diff --git a/examples/serialport/terminal/settingsdialog.h b/examples/serialport/terminal/settingsdialog.h
index ea249c1..4c0cda1 100644
--- a/examples/serialport/terminal/settingsdialog.h
+++ b/examples/serialport/terminal/settingsdialog.h
@@ -53,9 +53,7 @@
#define SETTINGSDIALOG_H
#include <QDialog>
-#include <QtSerialPort/QSerialPort>
-
-QT_USE_NAMESPACE
+#include <QSerialPort>
QT_BEGIN_NAMESPACE
@@ -104,9 +102,9 @@ private:
void updateSettings();
private:
- Ui::SettingsDialog *ui;
- Settings currentSettings;
- QIntValidator *intValidator;
+ Ui::SettingsDialog *m_ui = nullptr;
+ Settings m_currentSettings;
+ QIntValidator *m_intValidator = nullptr;
};
#endif // SETTINGSDIALOG_H