summaryrefslogtreecommitdiff
path: root/examples/terminal/mainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/terminal/mainwindow.cpp')
-rw-r--r--examples/terminal/mainwindow.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/examples/terminal/mainwindow.cpp b/examples/terminal/mainwindow.cpp
index cde83e1..b394b7d 100644
--- a/examples/terminal/mainwindow.cpp
+++ b/examples/terminal/mainwindow.cpp
@@ -69,6 +69,10 @@ MainWindow::MainWindow(QWidget *parent) :
ui->actionConfigure->setEnabled(true);
initActionsConnections();
+
+ connect(serial, SIGNAL(error(QSerialPort::SerialPortError)), this,
+ SLOT(handleError(QSerialPort::SerialPortError)));
+
//! [2]
connect(serial, SIGNAL(readyRead()), this, SLOT(readData()));
//! [2]
@@ -158,6 +162,16 @@ void MainWindow::readData()
}
//! [7]
+//! [8]
+void MainWindow::handleError(QSerialPort::SerialPortError error)
+{
+ if (error == QSerialPort::ResourceError) {
+ QMessageBox::critical(this, tr("Critical Error"), serial->errorString());
+ closeSerialPort();
+ }
+}
+//! [8]
+
void MainWindow::initActionsConnections()
{
connect(ui->actionConnect, SIGNAL(triggered()), this, SLOT(openSerialPort()));