如何修复“QtCharts"未找到库文件/无法包含 <QtCharts>? [英] How to fix "QtCharts" library file not found/can't include <QtCharts>?

查看:150
本文介绍了如何修复“QtCharts"未找到库文件/无法包含 <QtCharts>?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Qt GUI/Widget 应用程序的新手,我正在尝试制作一个简单的条形图.我试图复制 QT 在其网站 [link] 中提供的完全相同的代码:https://doc-snapshots.qt.io/qt5-5.11/qtcharts-barchart-example.html#creating-bar-charts.但是,我不断收到很多错误消息,提示找不到QtCharts"文件和QBarSet"Qlegend",基本上每个包含的库都没有找到.

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.

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

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

我的代码如下所示:

//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!

推荐答案

我刚刚意识到我没有安装 QT Charts 的组件/子模块,正如 eyllanesc 所提到的.我不得不重新安装 QT 并启用 QT 图表组件.您可以使用 QT 维护工具添加它,但我没有它,所以我重新安装了它,因为我仍然有安装程序.

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.

参考:如何在 Qt Creator 4.2.0(社区)中包含 QtCharts 库

这篇关于如何修复“QtCharts"未找到库文件/无法包含 <QtCharts>?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆