1

I am currently working on a C++ application for controlling an instrument. The instrument output should be displayed using a QChart. For the display I created a Qt user interface with a QChartView widget.

Here is the header file for the display class:

#pragma once

#include <QWidget>

#include "QtCharts\qchart.h"
#include <QtCharts\qchartview.h>
#include <QtCharts\qscatterseries.h>
#include <QtCharts\qlineseries.h>

#include "ui_ChartsDisplay.h"
#include <qthread.h>



using namespace QtCharts;

class ChartsDisplay : public QWidget
{
    Q_OBJECT

public:
    ChartsDisplay(QWidget *parent = Q_NULLPTR);
    ~ChartsDisplay();

private:
    Ui::ChartsDisplay ui;
    QLineSeries *trace,*retrace,*arbitrarySeriesX,*arbitrarySeriesY;
    QChart *chart;

    //QLogValueAxis *axisX, *axisY;

    void rescaleChart();


public slots:
    void SLUpdateChart(float *newValues);
    void SLSetupChartDisplay(int type);
    void SLResetChart();

    void SLUpdateNoise(float** newValues, int size);
};

I need two instances of the ChartDisplay class. One with linear and one with logarithmmic scaling for displaying different data types.

I found a Qt tutorial on using logarithmic axis scaling here:

https://doc.qt.io/qt-5/qtcharts-logvalueaxis-example.html

However, once I include "qlogvalueaxis.h" my programm will no longer compile. I get a long list of syntax errors originating in "qlogvalueaxis.h".

I created a new Qt project and implemented a simple chart with logarithmic scaling using qlogvalueaxis which worked fine. Also I cleaned the whole project and removed all qt generated files before compiling. The problem still remained. All necessary libraries are linked and up to date as are the header files.

Some information about the environment: -Visual Studio 2015, community edition -Qt framework 5.8 -Operating system is Win 7

Any would appreciate any advice.

Best regards, T. Krastev

T.Krastev
  • 83
  • 4
  • Any example of error ? – Marco Nov 07 '17 at 11:33
  • For example: Code: C2238 Description: unexpected token(s) preceding ';' Project: MacroAFM File: C:\Program Files (x86)\Qt\5.8\msvc2015\include\QtCharts\qlogvalueaxis.h Line: 84 This error occurs 3 times at the same line in the same file. So I suppose there is some conflict with other includes. – T.Krastev Nov 07 '17 at 16:49

1 Answers1

2

I had a similar (or perhaps the same) problem. I got compile errors indicating that the min() and max() function prototypes were already declared elsewhere, so if this is the case for you simply omit the min and max macros by adding the following before including the QtCharts headers:

#ifdef max
#undef max
#endif

#ifdef min
#undef min
#endif
Magnus
  • 36
  • 1