首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何修复未找到/不能包含<QtCharts>的"QtCharts“库文件?

如何修复未找到/不能包含<QtCharts>的"QtCharts“库文件?
EN

Stack Overflow用户
提问于 2019-06-09 18:46:41
回答 1查看 5.5K关注 0票数 2

我是Qt GUI/Widget应用程序的新手,我正在尝试制作一个简单的条形图。我试图复制QT在他们的网站上提供的完全相同的代码,链接:https://doc-snapshots.qt.io/qt5-5.11/qtcharts-barchart-example.html#creating-bar-charts。然而,我一直收到很多错误消息,说"QtCharts“文件找不到,"QBarSet”"QLegend“找不到,基本上每个包含的库都找不到。

我在QT网站上看到一些疑难解答页面,它说我必须在我的.qml文件中添加一些导入语句。但是我好像找不到.qml文件在哪里?链接:https://doc.qt.io/qt-5/qtcharts-index.html

我的代码看起来就像这样:

代码语言:javascript
复制
//main.cpp
----------
[link]: https://doc-snapshots.qt.io/qt5-5.11/qtcharts-barchart-main-cpp.html
代码语言:javascript
复制
//.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

如何修复/使代码正常工作?我真的不知道如何修复错误消息。谢谢!

EN

回答 1

Stack Overflow用户

发布于 2019-06-09 22:43:48

我刚刚意识到我没有安装QT图表的组件/子模块,正如eyllanesc所提到的那样。我不得不重新安装QT并启用QT图表组件。你可以用QT Maintenence工具添加它,但我没有,所以我只是重新安装它,因为我仍然有安装程序。

参考:How to include the QtCharts library in Qt Creator 4.2.0 (Community)

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56513925

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档