Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QCharts, "undeclared identifier"--what's wrong with it?
I wrote this line in my .pro file, and then, include these .h file successfully: :
but, it show me an error:
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
Gojir4 last edited by
using namespace QtCharts;is necessary in order to recognize types from QtCharts module
you have to rerun qmake after adding a module in your pro file
- clean project
- run qmake
- build project
should fix your problem
@Gojir4 oh I forgot this, thanks so much
@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?
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.
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.
I am pretty sure I needn't clean and run qmake, and MyBtn could be identified in Qt4.
@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).
@jsulm I got it, very thanks for your answer.
PENG.HU last edited by
You should add "QT_CHARTS_USE_NAMESPACE" first.