# HG changeset patch # User Hasan Yavuz Ă–ZDERYA # Date 2015-05-28 09:57:27 # Node ID f918be7cd46f3397800985c7be1425d3a6186ca7 # Parent 4cc4bd170d6a80d347ee7ae35465235947138b4a added log widget for error and warning messages diff --git a/main.cpp b/main.cpp --- a/main.cpp +++ b/main.cpp @@ -19,12 +19,24 @@ #include "mainwindow.h" #include +#include + +MainWindow* pMainWindow; + +void messageHandler(QtMsgType type, const QMessageLogContext &context, + const QString &msg) +{ + pMainWindow->messageHandler(type, context, msg); +} int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; + pMainWindow = &w; + + qInstallMessageHandler(messageHandler); + w.show(); - return a.exec(); } diff --git a/mainwindow.cpp b/mainwindow.cpp --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -28,6 +28,8 @@ #include #include #include +#include + #include "utils.h" #include "version.h" @@ -598,3 +600,11 @@ void MainWindow::onExportCsv() } } } + +void MainWindow::messageHandler(QtMsgType type, + const QMessageLogContext &context, + const QString &msg) +{ + ui->ptLog->appendPlainText(msg); + std::cerr << msg.toStdString() << std::endl; +} diff --git a/mainwindow.h b/mainwindow.h --- a/mainwindow.h +++ b/mainwindow.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include "portcontrol.h" @@ -46,6 +47,9 @@ public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); + void messageHandler(QtMsgType type, const QMessageLogContext &context, + const QString &msg); + private: enum NumberFormat { diff --git a/mainwindow.ui b/mainwindow.ui --- a/mainwindow.ui +++ b/mainwindow.ui @@ -16,7 +16,7 @@ - + 0 @@ -304,6 +304,35 @@ + + + Log + + + Error and Warning Messages + + + + 4 + + + 4 + + + 4 + + + 4 + + + + + true + + + + + @@ -392,7 +421,7 @@ QwtPlot - QWidget + QFrame
qwt_plot.h
1