我使用的是Visual Studio2019社区x64,Qt版本5.15.2。我已在项目->属性-> Qt项目设置-> Qt模块中安装并选择了“图表”模块
我的代码:
#include <QCandlestickSet>
struct Bar
{
double open, close, high, low;
qint64 timestamp;
Bar() : open(0.0), close(0.0), high(0.0), low(0.0), timestamp(0)
{
}
QCandlestickSet * toCandle(void)
{
return new QCandlestickSet(this->open, this->high, this->low, this->close, this->timestamp);
}
};我得到了错误:
严重性代码说明项目文件行抑制状态错误(激活) E0020标识符"QCandlestickSet“未定义ProjectName ..\Bar.h 27
任何帮助都将不胜感激。
提前谢谢你。
发布于 2021-11-23 12:30:03
正如G.M.在评论中提到的,所有与QtChart相关的内容都保存在一个名为QtCharts的名称空间中。
执行以下任一操作都可以解决此问题:
using QtCharts::QCandlestickSet;或者
using namespace QtCharts;或者
QtCharts::QCandlestickSet * toCandle(void)
{
return new QtCharts::QCandlestickSet(this->open, this->high, this->low, this->close, this->timestamp);
}虽然在与QCandlestickSet相关的页面中没有提到命名空间,但在QtCharts page中提到了它
https://stackoverflow.com/questions/70080350
复制相似问题