c++ - 不能包含 <QtCharts/QLineSeries>

标签 c++ qt qtcharts

我似乎找不到包含 <QtCharts/QLineSeries> 的方法在我的标题中,以便 Qt 知道 QLineSeries 类。

  • 我添加了 Qt += charts到我的 .pro 文件。
  • 我添加了 #include <QtCharts/QLineSeries>MainWindow.h
  • 然后我删除 .pro.user 文件和我完成的所有构建。然后重新打开 .pro 文件以最干净的方式重新配置项目。
  • 最后我将构建模式设置为 Release ,通过右键单击项目并选择它并运行来运行 QMake。

我收到消息:

 ...\PlottingCharts\mainwindow.h:14: error: 'QLineSeries' does not name a type
     QLineSeries *series;
     ^

很明显 Qt 对 QLineSeries 一无所知。

作为引用,linechartopenglseries示例工作正常。

有人知道我错过了什么吗?

最佳答案

我在写问题时找到了答案。

我在头文件中缺少 using namespace QtCharts;。 从以下位置获得引用:http://doc.qt.io/qt-5/qtcharts-index.html

关于c++ - 不能包含 <QtCharts/QLineSeries>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38802982/

相关文章:

qt - 从 QML url 获取路径

c++ - 在 TreeView 中滚动时 Qt QAbstractItemModel 变慢

python - 如何在 QHorizo​​ntalBarSeries/QChart 的指定 x 值处画一条垂直线?

python - 如何更改 PySide2 中图表的颜色

c++ - 如何使用 pdb 调试现有的 C++ 可执行文件但没有源代码

c++ - 如何在自己的方法中使用 lambda 表达式

c++ - 没有用于调用 std::vector<std::tuple> push_back 的匹配函数

c++ - 在具有多个 y 轴的 Qt 图表中显示工具提示

c++ - 将 NSTimer 添加到 C++ 类

c++ - 桶排序和用户输入