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)
Forum Updated to NodeBB v4.3 + New Features

Syntax Errors When Including Header (QChart Headers)

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 6 Posters 2.6k Views 2 Watching
  • 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 Offline
    R Offline
    R_Irudezu
    wrote on 10 Dec 2018, 23:24 last edited by R_Irudezu 12 Oct 2018, 23:26
    #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.

    M 1 Reply Last reply 11 Dec 2018, 00:07
    0
    • R R_Irudezu
      10 Dec 2018, 23:24

      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)

      M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 11 Dec 2018, 00:07 last edited by
      #2

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

      R 1 Reply Last reply 11 Dec 2018, 00:17
      0
      • M mrjj
        11 Dec 2018, 00:07

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

        R Offline
        R Offline
        R_Irudezu
        wrote on 11 Dec 2018, 00:17 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
        • D Offline
          D Offline
          dheerendra
          Qt Champions 2022
          wrote on 11 Dec 2018, 01:34 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 1 Reply Last reply 11 Dec 2018, 02:28
          2
          • 6 Offline
            6 Offline
            6thC
            wrote on 11 Dec 2018, 02:08 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
            • D dheerendra
              11 Dec 2018, 01:34

              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 Offline
              R Offline
              R_Irudezu
              wrote on 11 Dec 2018, 02:28 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
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 11 Dec 2018, 07:12 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
                • 6 Offline
                  6 Offline
                  6thC
                  wrote on 12 Dec 2018, 02:50 last edited by 6thC 12 Dec 2018, 02:52
                  #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?

                  J 1 Reply Last reply 12 Dec 2018, 07:01
                  0
                  • 6 6thC
                    12 Dec 2018, 02:50

                    @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?

                    J Offline
                    J Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on 12 Dec 2018, 07:01 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
                    • 6 Offline
                      6 Offline
                      6thC
                      wrote on 12 Dec 2018, 23:47 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

                      J 1 Reply Last reply 13 Dec 2018, 05:51
                      0
                      • 6 6thC
                        12 Dec 2018, 23:47

                        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

                        J Offline
                        J Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on 13 Dec 2018, 05:51 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
                        • 6 Offline
                          6 Offline
                          6thC
                          wrote on 13 Dec 2018, 06:35 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

                          9/12

                          12 Dec 2018, 07:01

                          • Login

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