From 085a5bb3fccbe6cc1f47e10d6232e54438dae7b4 Mon Sep 17 00:00:00 2001 From: Andre Hartmann Date: Wed, 29 Jun 2016 19:45:50 +0200 Subject: CAN-Example: Close connect dialog on exit Before, the connect dialog stayed open when the main window was already closed. Change-Id: I36734ab4ed4cea9e6e4c7a7ead11bb382b828f21 Reviewed-by: Alex Blasche --- examples/serialbus/can/mainwindow.cpp | 7 +++++++ examples/serialbus/can/mainwindow.h | 3 +++ 2 files changed, 10 insertions(+) (limited to 'examples/serialbus') diff --git a/examples/serialbus/can/mainwindow.cpp b/examples/serialbus/can/mainwindow.cpp index a04a0f4..0c6790b 100644 --- a/examples/serialbus/can/mainwindow.cpp +++ b/examples/serialbus/can/mainwindow.cpp @@ -44,6 +44,7 @@ #include #include +#include #include #include @@ -170,6 +171,12 @@ void MainWindow::framesWritten(qint64 count) qDebug() << "Number of frames written:" << count; } +void MainWindow::closeEvent(QCloseEvent *event) +{ + m_connectDialog->close(); + event->accept(); +} + static QByteArray dataToHex(const QByteArray &data) { QByteArray result = data.toHex().toUpper(); diff --git a/examples/serialbus/can/mainwindow.h b/examples/serialbus/can/mainwindow.h index aff6c94..de4d442 100644 --- a/examples/serialbus/can/mainwindow.h +++ b/examples/serialbus/can/mainwindow.h @@ -74,6 +74,9 @@ private Q_SLOTS: void disconnectDevice(); void framesWritten(qint64); +protected: + void closeEvent(QCloseEvent *event); + private: void showStatusMessage(const QString &message); void initActionsConnections(); -- cgit v1.2.3