Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. Qtcharts with visual C++

Qtcharts with visual C++

Scheduled Pinned Locked Moved Unsolved 3rd Party Software
visual c++namespaceqtcharts
2 Posts 2 Posters 1.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    awawawa
    wrote on 17 Aug 2016, 08:50 last edited by
    #1

    Hi everybody!

    I am working on a project on visual c++ and I try to add a form class with a QChartView inside. In this project :

    • After adding the QtCharts directoy folder and linking qt5Charts.lib with my project,

    • I draw a form with QtDesigner

    • I add a Widget that I promote as a QChartView.

    When I try to compile my project, I have some errors. The origin of these errors seems that in the generated ui_XXX.h of my form, the namespace qtCharts is not used. If I add it manually, the project will compile and seems to work well. The problem is that the line I add is deleted each time the ui_XXX.h is generated.

    Can you, please, tell me, what point which will fixe this probleme that I forgot?

    Here is some part of the code :

    • Here is the class that I create :
    #ifndef TEST_H
    #define TEST_H
    #include "ui_test.h"
    
    class test : public QMainWindow
    {
    	Q_OBJECT
    public:
    	test(QWidget *parent = 0);
    	~test();
    private:
    	Ui::testClass ui;	
    };
    #endif // TEST_H
    

    This class contains a Ui::testClass element which is generated by the QtDesigner. Here is the code :

    
    #ifndef UI_TEST_H
    #define UI_TEST_H
    
    #include <QtCore/QVariant>
    #include <QtWidgets/QAction>
    #include <QtWidgets/QApplication>
    #include <QtWidgets/QButtonGroup>
    #include <QtWidgets/QHeaderView>
    #include <QtWidgets/QMainWindow>
    #include <QtWidgets/QMenuBar>
    #include <QtWidgets/QStatusBar>
    #include <QtWidgets/QToolBar>
    #include <QtWidgets/QWidget>
    #include "QtCharts\qchartview.h"
    
    QT_BEGIN_NAMESPACE
    
    //using namespace QtCharts; I have to add this line if I want the compilation works
    
    class Ui_testClass
    {
    public:
        QWidget *centralWidget;
        QChartView *widget; // without namespace this must be QtCharts::QChartView
        QMenuBar *menuBar;
        QToolBar *mainToolBar;
        QStatusBar *statusBar;
    
    //BLA BLA BLA...
    
    D 1 Reply Last reply 17 Aug 2016, 12:16
    0
    • A awawawa
      17 Aug 2016, 08:50

      Hi everybody!

      I am working on a project on visual c++ and I try to add a form class with a QChartView inside. In this project :

      • After adding the QtCharts directoy folder and linking qt5Charts.lib with my project,

      • I draw a form with QtDesigner

      • I add a Widget that I promote as a QChartView.

      When I try to compile my project, I have some errors. The origin of these errors seems that in the generated ui_XXX.h of my form, the namespace qtCharts is not used. If I add it manually, the project will compile and seems to work well. The problem is that the line I add is deleted each time the ui_XXX.h is generated.

      Can you, please, tell me, what point which will fixe this probleme that I forgot?

      Here is some part of the code :

      • Here is the class that I create :
      #ifndef TEST_H
      #define TEST_H
      #include "ui_test.h"
      
      class test : public QMainWindow
      {
      	Q_OBJECT
      public:
      	test(QWidget *parent = 0);
      	~test();
      private:
      	Ui::testClass ui;	
      };
      #endif // TEST_H
      

      This class contains a Ui::testClass element which is generated by the QtDesigner. Here is the code :

      
      #ifndef UI_TEST_H
      #define UI_TEST_H
      
      #include <QtCore/QVariant>
      #include <QtWidgets/QAction>
      #include <QtWidgets/QApplication>
      #include <QtWidgets/QButtonGroup>
      #include <QtWidgets/QHeaderView>
      #include <QtWidgets/QMainWindow>
      #include <QtWidgets/QMenuBar>
      #include <QtWidgets/QStatusBar>
      #include <QtWidgets/QToolBar>
      #include <QtWidgets/QWidget>
      #include "QtCharts\qchartview.h"
      
      QT_BEGIN_NAMESPACE
      
      //using namespace QtCharts; I have to add this line if I want the compilation works
      
      class Ui_testClass
      {
      public:
          QWidget *centralWidget;
          QChartView *widget; // without namespace this must be QtCharts::QChartView
          QMenuBar *menuBar;
          QToolBar *mainToolBar;
          QStatusBar *statusBar;
      
      //BLA BLA BLA...
      
      D Offline
      D Offline
      Devopia53
      wrote on 17 Aug 2016, 12:16 last edited by
      #2

      @awawawa

      Hi.

      Try in your test.h as follows:

      #ifndef TEST_H
      #define TEST_H
      
      #include <QtCharts>
      QT_CHARTS_USE_NAMESPACE
      
      #include <QMainWindow>
      #include "ui_test.h"
      
      class test : public QMainWindow
      {
      [...]
      

      Do not modify your ui_test.h.

      1 Reply Last reply
      0

      1/2

      17 Aug 2016, 08:50

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved