How to inclide #include <QtCharts> library to qt project
-
Hi I downloaded qt 5.9.3 and would like to make diagrams but qt dont see <QtCharts> library how is it possible to resolve it (where to load the library)
-
Make sure the QtCharts module is installed. Then, make sure it is included in your .pro file:
QT += charts
Also, read this: https://doc.qt.io/qt-5/qtcharts-index.html
-
Never seen that one myself. Have you installed Qt 5.9.3 from the offline package? Try using online installer instead.
Or you can provide repository URL in settings, if you know them. I don't know the URLs.
-
@sierdzio i find about the problem stackoverflow but it does not help I downoload qt using this link , could I give your download link if <QtCharts> library is available there , thanks
-
Try the online installer https://www1.qt.io/download-open-source/
Anyway, in your current installation, is QtCharts checkbox checked? Maybe you have it already and do not need to do anything (apart form fixing the .pro file).
I haven't asked, but just to be sure: the code does not compile for you, right?
-
That only tells me that Qt Creator does not see it. It may still compile.
-
@mark_ua_1999
There are 2 QtCharts files involved here. Try to understand the difference between:#include <QtCharts>
in your source code, which is looking for the header file (I'm not a C++ expert, I can't recall whether the file is named plainQtCharts
or isQtCharts.h
, but I think it's the latter)QT += charts
in your.pro
file, which is looking for the library file to link against (QtCharts.lib
orlibQtCharts.a
or something --- actually it may be.dll
/.so
)
First you need to verify you actually have the necessary two files. Then the header file will need to be found via something like (I don't use QtCreator either) the
INCLUDE
used in your Qt project, while the library file will need to be foundLIBS
. -
@mark_ua_1999
I don't think you should be downloading individual files and figuring where to put them yourself. I believe you need to sort out why you are not able to get the necessary files via the proper install/maintenance tool, it will cause less later grief to get this right. Not my area as to why you are having trouble when others are claiming it should be straightforward.... -
@mark_ua_1999
@sierdzio said in How to inclide #include <QtCharts> library to qt project:Never seen that one myself. Have you installed Qt 5.9.3 from the offline package? Try using online installer instead.
Or you can provide repository URL in settings, if you know them. I don't know the URLs.
You didn't answer @sierdzio's question? The wording of the red error message you got suggests to me that your installation does not know where to look to fetch further Qt packages from, hence your problem?
-
@JNBarchan said in How to inclide #include <QtCharts> library to qt project:
You didn't answer @sierdzio's question?
He kind of did. He's using the offline installer, so the repos are not there. I recommend going with the online installer, it will all simply work. (although to be honest I think QtCharts are included also in offline installer. Dunno, though, I haven't tried it in years).
Anyway, he has some pointers where the issue can be, if he wants to he will sort it out.