I'm new to Qt GUI/Widget Application and I am trying to make a simple bar chart. I tried to copy the exact same code that QT provides in their website, [link]: https://doc-snapshots.qt.io/qt5-5.11/qtcharts-barchart-example.html#creating-bar-charts. However, I keep getting a lot of error message that says "QtCharts" file not found and "QBarSet" "QLegend" not found, basically every library that was included was not found.
I saw some troubleshoot page in QT website, it says that I have to add some import statement in my .qml file. But I can't seem to find where is the .qml file located? [link]: https://doc.qt.io/qt-5/qtcharts-index.html
My code looks exactly like this:
//main.cpp
----------
[link]: https://doc-snapshots.qt.io/qt5-5.11/qtcharts-barchart-main-cpp.html
//.pro file
------------
QT += core gui charts
//I only add "charts" in the above line from the original .pro file
//everything else is the exact same .pro file as in the original.
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = testing_file
TEMPLATE = app
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui
How do you fix/make the code works? I really have no idea how to fix the error messages. Thanks!
I just realized I did not install the components/submodule of QT Charts, as mentioned by eyllanesc. I had to reinstall the QT all over again and enable the QT Charts components. You can add it with QT Maintenence tool but I didn't have it so I just reinstall it again because I still got the installer.
Reference: How to include the QtCharts library in Qt Creator 4.2.0 (Community)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With