Changeset - f918be7cd46f
[Not reviewed]
default
0 4 0
Hasan Yavuz Ă–ZDERYA - 10 years ago 2015-05-28 09:57:27
hy@ozderya.net
added log widget for error and warning messages
4 files changed with 58 insertions and 3 deletions:
0 comments (0 inline, 0 general)
main.cpp
Show inline comments
 
@@ -19,12 +19,24 @@
 

	
 
#include "mainwindow.h"
 
#include <QApplication>
 
#include <QtGlobal>
 

	
 
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();
 
}
mainwindow.cpp
Show inline comments
 
@@ -28,6 +28,8 @@
 
#include <qwt_plot.h>
 
#include <limits.h>
 
#include <cmath>
 
#include <iostream>
 

	
 
#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;
 
}
mainwindow.h
Show inline comments
 
@@ -29,6 +29,7 @@
 
#include <QSignalMapper>
 
#include <QTimer>
 
#include <QColor>
 
#include <QtGlobal>
 
#include <qwt_plot_curve.h>
 

	
 
#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
 
    {
mainwindow.ui
Show inline comments
 
@@ -16,7 +16,7 @@
 
  <widget class="QWidget" name="centralWidget">
 
   <layout class="QVBoxLayout" name="verticalLayout_2">
 
    <item>
 
     <widget class="QwtPlot" name="plot" native="true">
 
     <widget class="QwtPlot" name="plot">
 
      <property name="sizePolicy">
 
       <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
 
        <horstretch>0</horstretch>
 
@@ -304,6 +304,35 @@
 
        </item>
 
       </layout>
 
      </widget>
 
      <widget class="QWidget" name="tabLog">
 
       <attribute name="title">
 
        <string>Log</string>
 
       </attribute>
 
       <attribute name="toolTip">
 
        <string>Error and Warning Messages</string>
 
       </attribute>
 
       <layout class="QHBoxLayout" name="horizontalLayout">
 
        <property name="leftMargin">
 
         <number>4</number>
 
        </property>
 
        <property name="topMargin">
 
         <number>4</number>
 
        </property>
 
        <property name="rightMargin">
 
         <number>4</number>
 
        </property>
 
        <property name="bottomMargin">
 
         <number>4</number>
 
        </property>
 
        <item>
 
         <widget class="QPlainTextEdit" name="ptLog">
 
          <property name="readOnly">
 
           <bool>true</bool>
 
          </property>
 
         </widget>
 
        </item>
 
       </layout>
 
      </widget>
 
     </widget>
 
    </item>
 
   </layout>
 
@@ -392,7 +421,7 @@
 
 <customwidgets>
 
  <customwidget>
 
   <class>QwtPlot</class>
 
   <extends>QWidget</extends>
 
   <extends>QFrame</extends>
 
   <header>qwt_plot.h</header>
 
   <container>1</container>
 
  </customwidget>
0 comments (0 inline, 0 general)