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. QCharts, "undeclared identifier"--what's wrong with it?
Forum Updated to NodeBB v4.3 + New Features

QCharts, "undeclared identifier"--what's wrong with it?

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 5 Posters 2.2k Views 1 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.
  • DonationD Offline
    DonationD Offline
    Donation
    wrote on last edited by
    #1

    I wrote this line in my .pro file, and then, include these .h file successfully: :
    0_1559741380311_c12f19d3-6fea-4e76-9f9b-397ea5685bb4-image.png

    0_1559741463522_f8dae2b2-27e0-49f5-a521-4ba96aeb3f41-image.png
    but, it show me an error:
    0_1559741549635_1a2ef22d-f45c-489b-8199-5617b929d9fb-image.png
    why it happens, I did same work in another project, and that project have no error.
    Is it a bug? I have no mind right now, maybe somebody could tell me how to do? thanks

    Gojir4G J.HilkJ 2 Replies Last reply
    0
    • DonationD Donation

      I wrote this line in my .pro file, and then, include these .h file successfully: :
      0_1559741380311_c12f19d3-6fea-4e76-9f9b-397ea5685bb4-image.png

      0_1559741463522_f8dae2b2-27e0-49f5-a521-4ba96aeb3f41-image.png
      but, it show me an error:
      0_1559741549635_1a2ef22d-f45c-489b-8199-5617b929d9fb-image.png
      why it happens, I did same work in another project, and that project have no error.
      Is it a bug? I have no mind right now, maybe somebody could tell me how to do? thanks

      Gojir4G Offline
      Gojir4G Offline
      Gojir4
      wrote on last edited by
      #2

      @Donation Hi,

      using namespace QtCharts; is necessary in order to recognize types from QtCharts module

      DonationD 1 Reply Last reply
      0
      • DonationD Donation

        I wrote this line in my .pro file, and then, include these .h file successfully: :
        0_1559741380311_c12f19d3-6fea-4e76-9f9b-397ea5685bb4-image.png

        0_1559741463522_f8dae2b2-27e0-49f5-a521-4ba96aeb3f41-image.png
        but, it show me an error:
        0_1559741549635_1a2ef22d-f45c-489b-8199-5617b929d9fb-image.png
        why it happens, I did same work in another project, and that project have no error.
        Is it a bug? I have no mind right now, maybe somebody could tell me how to do? thanks

        J.HilkJ Online
        J.HilkJ Online
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        @Donation

        you have to rerun qmake after adding a module in your pro file

        • clean project
        • run qmake
        • build project

        should fix your problem


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        DonationD 1 Reply Last reply
        1
        • Gojir4G Gojir4

          @Donation Hi,

          using namespace QtCharts; is necessary in order to recognize types from QtCharts module

          DonationD Offline
          DonationD Offline
          Donation
          wrote on last edited by
          #4

          @Gojir4 oh I forgot this, thanks so much

          1 Reply Last reply
          0
          • J.HilkJ J.Hilk

            @Donation

            you have to rerun qmake after adding a module in your pro file

            • clean project
            • run qmake
            • build project

            should fix your problem

            DonationD Offline
            DonationD Offline
            Donation
            wrote on last edited by
            #5

            @J.Hilk Qt4 seems don't need that, right? I'm not sure.
            I mean, if I change the UI in Qt Designer and the .ui file changed, it always ask me clean the project and run qmake, then build it. But Qt4 seems needn't do that, right?

            J.HilkJ 1 Reply Last reply
            0
            • DonationD Donation

              @J.Hilk Qt4 seems don't need that, right? I'm not sure.
              I mean, if I change the UI in Qt Designer and the .ui file changed, it always ask me clean the project and run qmake, then build it. But Qt4 seems needn't do that, right?

              J.HilkJ Online
              J.HilkJ Online
              J.Hilk
              Moderators
              wrote on last edited by
              #6

              @Donation
              I'm not entirely sure, as I experienced Qt4 only briefly, before it was replaced by Qt5.

              But it seems highly unlikely, that it would not require it.


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              DonationD 1 Reply Last reply
              0
              • J.HilkJ J.Hilk

                @Donation
                I'm not entirely sure, as I experienced Qt4 only briefly, before it was replaced by Qt5.

                But it seems highly unlikely, that it would not require it.

                DonationD Offline
                DonationD Offline
                Donation
                wrote on last edited by
                #7

                @J.Hilk
                Maybe I didn't say it clearly last time. I mean, if I change the .ui file, such as add a pushButton named MyBtn, and save it, it would ask me to do these: clean project -> run qmake. Otherwise you will get a error, it can't be identified.
                0_1560417794352_4b58ce50-7377-4f52-85ae-d65e81934f49-image.png

                0_1560417863643_30174bf7-1f64-4d58-911f-af3a7158f98c-image.png

                I am pretty sure I needn't clean and run qmake, and MyBtn could be identified in Qt4.

                jsulmJ 1 Reply Last reply
                0
                • DonationD Donation

                  @J.Hilk
                  Maybe I didn't say it clearly last time. I mean, if I change the .ui file, such as add a pushButton named MyBtn, and save it, it would ask me to do these: clean project -> run qmake. Otherwise you will get a error, it can't be identified.
                  0_1560417794352_4b58ce50-7377-4f52-85ae-d65e81934f49-image.png

                  0_1560417863643_30174bf7-1f64-4d58-911f-af3a7158f98c-image.png

                  I am pretty sure I needn't clean and run qmake, and MyBtn could be identified in Qt4.

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

                  @Donation It's not related to Qt, it is a QtCreator + qmake thing. Changes in ui files are often only recognised in C++ code in QtCreator after building the project. The reason is that the code model only parses C++ files not ui files, so first ui XML files need to be translated into C++ files (with ui_ prefix).

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

                  DonationD 1 Reply Last reply
                  3
                  • jsulmJ jsulm

                    @Donation It's not related to Qt, it is a QtCreator + qmake thing. Changes in ui files are often only recognised in C++ code in QtCreator after building the project. The reason is that the code model only parses C++ files not ui files, so first ui XML files need to be translated into C++ files (with ui_ prefix).

                    DonationD Offline
                    DonationD Offline
                    Donation
                    wrote on last edited by
                    #9

                    @jsulm I got it, very thanks for your answer.

                    1 Reply Last reply
                    0
                    • P Offline
                      P Offline
                      PENG.HU
                      wrote on last edited by
                      #10

                      You should add "QT_CHARTS_USE_NAMESPACE" first.

                      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