awawa
awawa

Reputation: 21

QtChartView missing namespace in the generated UI file

I am working on visual c++ with the Qt Framework.

I am trying to add a QChartView in a project. I added the included paths and the files to link.

When I try to make compilation, I have a lot of syntaxe error in my code. These come from the fact that in the generated UI_XXX.h file (I use QtDesigner), the namespache QtCharts is not used. The problem is that I can not add the line manually in this generated file : it will be deleted at every change of the form.

I would like the make the compiler use the QtCharts namespace inside the class Ui_XXX.h generated but without editing this Ui_XXX.h

How can I do?


To illustrate, here is the a part of my code:

#include<qchartview.h>

class test : public QMainWindow
{
    Q_OBJECT

public:
    test(QWidget *parent = 0);
    ~test();    

private:
    Ui_testClass ui; //---> here is the generated class by QtDesign. I want to use qtCharts namespace here

};

Here is a part of the UI_XXX.h generated class

#include <QtWidgets/QWidget>
#include "qchartview.h"

QT_BEGIN_NAMESPACE


//using namespace QtCharts-----> if I put this line it will works. But these line will be deleted when recompiling the UI file


class Ui_testClass
{
public:
    QWidget *centralWidget;
    QChartView *widget;
    QMenuBar *menuBar;
    QToolBar *mainToolBar;
    QStatusBar *statusBar;
    QToolBar *toolBar;

Upvotes: 2

Views: 29

Answers (0)

Related Questions