简体   繁体   English

QCandlestickSet 未定义 C++ Qt5.15

[英]QCandlestickSet is undefined C++ Qt5.15

I'm using Visual Studio 2019 Community x64, Qt version 5.15.2.我正在使用 Visual Studio 2019 Community x64,Qt 版本 5.15.2。 I have the 'Charts' module installed and selected in Project -> Properties -> Qt Project Settings -> Qt Modules我在项目 -> 属性 -> Qt 项目设置 -> Qt 模块中安装并选择了“图表”模块

My code:我的代码:

#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);
    }
};

I am getting the error:我收到错误消息:

Severity Code Description Project File Line Suppression State Error (active) E0020 identifier "QCandlestickSet" is undefined ProjectName..\Bar.h 27严重性代码 描述 项目文件行抑制 State 错误(活动) E0020 标识符“QCandlestickSet”未定义 ProjectName..\Bar.h 27

Any help would be appreciated.任何帮助,将不胜感激。

Thank you in advance.先感谢您。

As mentioned in the comments by GM, everything QtChart related is held within a namespace called QtCharts.正如 GM 在评论中提到的,与 QtChart 相关的所有内容都保存在名为 QtCharts 的命名空间中。

Doing any of the following will fix this issue:执行以下任何操作都可以解决此问题:

using QtCharts::QCandlestickSet;

OR或者

using namespace QtCharts;

OR或者

QtCharts::QCandlestickSet * toCandle(void)
{
    return new QtCharts::QCandlestickSet(this->open, this->high, this->low, this->close, this->timestamp);
}

Although the namespace is not mentioned in the page relating to QCandlestickSet, it is mentioned on the QtCharts page虽然命名空间在与 QCandlestickSet 相关的页面中没有提到,但在QtCharts 页面中提到了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM