Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Syntax Errors When Including Header (QChart Headers)
QtWS25 Last Chance

Syntax Errors When Including Header (QChart Headers)

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 6 Posters 2.4k 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.
  • R_IrudezuR Offline
    R_IrudezuR Offline
    R_Irudezu
    wrote on last edited by R_Irudezu
    #1

    This is a weird error, i think it is concerned with namespaces but i don't know how to solve that.
    Problem is, when i include that line:
    0_1544484135386_6c3ecd76-a87c-4a32-ade4-190605a1a088-image.png

    this happens:
    0_1544484185767_te.PNG

    all my functions are in correct syntax but all of them throws syntax error when i include that line.
    What might be causes that?

    Edit: the header can be included in other project with no errors. (In a clean project, i mean empty ui project)

    Keizoku wa chikaranari.

    mrjjM 1 Reply Last reply
    0
    • R_IrudezuR R_Irudezu

      This is a weird error, i think it is concerned with namespaces but i don't know how to solve that.
      Problem is, when i include that line:
      0_1544484135386_6c3ecd76-a87c-4a32-ade4-190605a1a088-image.png

      this happens:
      0_1544484185767_te.PNG

      all my functions are in correct syntax but all of them throws syntax error when i include that line.
      What might be causes that?

      Edit: the header can be included in other project with no errors. (In a clean project, i mean empty ui project)

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @R_Irudezu
      Hi
      did you add
      QT += charts
      to the .pro file ?

      R_IrudezuR 1 Reply Last reply
      0
      • mrjjM mrjj

        @R_Irudezu
        Hi
        did you add
        QT += charts
        to the .pro file ?

        R_IrudezuR Offline
        R_IrudezuR Offline
        R_Irudezu
        wrote on last edited by
        #3

        @mrjj yes i added already, if i didn't the error would be shown with first QChart include, but it happens when i add QValueAxis.

        I think it might be header including order error but i can't find it. Or do i think wrong, maybe something different causes that...

        Keizoku wa chikaranari.

        1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          I think you may be doing something like including one.h in two.h and two.h in one.h file. Just check this round about.

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          R_IrudezuR 1 Reply Last reply
          2
          • 6thC6 Offline
            6thC6 Offline
            6thC
            wrote on last edited by
            #5

            Have you seen : https://doc.qt.io/qt-5.11/qtcharts-index.html

            Have you included QtCharts?

            Instead of that macro, I noticed a while back all the recent examples instead now use:

            #include <QtCharts>
            
            using namespace QtCharts;
            

            Just ideas, without code to reproduce we can only hit and miss assist. Not very efficient methods to troubleshoot.

            1 Reply Last reply
            0
            • dheerendraD dheerendra

              I think you may be doing something like including one.h in two.h and two.h in one.h file. Just check this round about.

              R_IrudezuR Offline
              R_IrudezuR Offline
              R_Irudezu
              wrote on last edited by
              #6

              @dheerendra yes it was like that and was very bad structure, when i included chart class first it solved.

              Keizoku wa chikaranari.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @6thC Don't use module wide includes. It might be fine for short examples and quick tests but it pulls in everything from said module which slows down compilation. Always only include what you use.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                4
                • 6thC6 Offline
                  6thC6 Offline
                  6thC
                  wrote on last edited by 6thC
                  #8

                  @SGaist can you elaborate because it's gone over my head. I was just going by: https://doc.qt.io/qt-5.11/qtcharts-index.html

                  If you intend to use Qt Charts C++ classes in your application, use the following include and using directives:
                  
                  #include <QtCharts>
                  
                  using namespace QtCharts;
                  

                  I'm the only dev here and so I have to learn all myself from reference material and examples.

                  I only use c++14, I don't think that even has modules?

                  jsulmJ 1 Reply Last reply
                  0
                  • 6thC6 6thC

                    @SGaist can you elaborate because it's gone over my head. I was just going by: https://doc.qt.io/qt-5.11/qtcharts-index.html

                    If you intend to use Qt Charts C++ classes in your application, use the following include and using directives:
                    
                    #include <QtCharts>
                    
                    using namespace QtCharts;
                    

                    I'm the only dev here and so I have to learn all myself from reference material and examples.

                    I only use c++14, I don't think that even has modules?

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @6thC said in Syntax Errors When Including Header (QChart Headers):

                    #include <QtCharts>

                    QtChart is called "module" in Qt. C++ does not have such a concept, so it's just a notation in Qt.
                    The problem with such includes is that it will include all header files from QtCharts. So, first preprocessor will need to handle all these includes and then compiler will get a lot more code to compile. This will slow down the build process as @SGaist said.
                    You should always include only what is really needed (not only when using Qt).

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    2
                    • 6thC6 Offline
                      6thC6 Offline
                      6thC
                      wrote on last edited by
                      #10

                      Oh right, yes, I agree with only including what you need!
                      This documentation then is really misleading to tell people, to include everything, I can't imagine this ever being a good idea as I very much love c++ for the use only what you need mentality.

                      I just didn't know if Qt was gearing up for c++ modules already... I suspected it was just a terminology thing. I also suspected that if the bible says this is how you get charts that this thing is necessary.

                      I've read both:
                      Qt 5.12 > All C++ APIs per Module
                      and
                      Qt 5.12 > All Modules
                      before, just never actually clicked. I think having team members and speaking aloud about things would have caught this gap sooner.

                      My qmake currently has:

                      QT += qml   quick  widgets  charts  network quickcontrols2 svg
                      

                      I suspect this will remain the same, like, I can't narrow this down any hey (best I can tell I cannot)?

                      Anyhow, thanks, you two @jsulm @SGaist. I'm happy to have learned and this is welcome information indeed. It's filled a few gaps I never knew I had.

                      This is pretty exciting to hear, I'm just plotting LineSeries values over time now - I'm probably going to be able to remove this now and go for:

                      #include <QChart> 
                      #include <QChartView> 
                      #include <QLineSeries>
                      #include <QDateTimeAxis>
                      #include <QValueAxis>
                      

                      Now I'm going to look for other <Qt includes and see if I've done this everywhere... it's already fast but to get leaner again is very welcome.

                      Sorry to feed you incorrect info and the little unintentional hijack @R_Irudezu

                      jsulmJ 1 Reply Last reply
                      0
                      • 6thC6 6thC

                        Oh right, yes, I agree with only including what you need!
                        This documentation then is really misleading to tell people, to include everything, I can't imagine this ever being a good idea as I very much love c++ for the use only what you need mentality.

                        I just didn't know if Qt was gearing up for c++ modules already... I suspected it was just a terminology thing. I also suspected that if the bible says this is how you get charts that this thing is necessary.

                        I've read both:
                        Qt 5.12 > All C++ APIs per Module
                        and
                        Qt 5.12 > All Modules
                        before, just never actually clicked. I think having team members and speaking aloud about things would have caught this gap sooner.

                        My qmake currently has:

                        QT += qml   quick  widgets  charts  network quickcontrols2 svg
                        

                        I suspect this will remain the same, like, I can't narrow this down any hey (best I can tell I cannot)?

                        Anyhow, thanks, you two @jsulm @SGaist. I'm happy to have learned and this is welcome information indeed. It's filled a few gaps I never knew I had.

                        This is pretty exciting to hear, I'm just plotting LineSeries values over time now - I'm probably going to be able to remove this now and go for:

                        #include <QChart> 
                        #include <QChartView> 
                        #include <QLineSeries>
                        #include <QDateTimeAxis>
                        #include <QValueAxis>
                        

                        Now I'm going to look for other <Qt includes and see if I've done this everywhere... it's already fast but to get leaner again is very welcome.

                        Sorry to feed you incorrect info and the little unintentional hijack @R_Irudezu

                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        @6thC said in Syntax Errors When Including Header (QChart Headers):

                        This documentation then is really misleading to tell people, to include everything

                        Do you mean https://doc.qt.io/qt-5.11/qtcharts-index.html ?
                        This is the starting point for the module in the documentation. If you go to a class in this module you will see that only the exact header is suggested, see for example https://doc.qt.io/qt-5.11/qbarset.html

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • 6thC6 Offline
                          6thC6 Offline
                          6thC
                          wrote on last edited by
                          #12

                          Yes that's the page I linked earlier.

                          Yes, I'm aware of that, that's how I normally use reference material. It's very nice to have. Reading this page when I started out seemed to indicate to me that I also needed to do this, which I do not.

                          It's ok, I've said my piece. I've learned, I was just trying to assist. I'm happy to leave it here.

                          1 Reply Last reply
                          0

                          • Login

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