在Visual Studio 2015中使用QCharts时未解析的外部符号

时间:2017-01-26 21:19:35

标签: c++ visual-studio qt

我正在使用Qt 5.7并使用随附的维护工具安装QCharts。我能够包含QChart和QLineSeries,因为这两个文件都在我的include目录中,但是我收到了LNK2001错误。我相信这是因为程序没有链接到库,但Qt5Charts位于我的Qt lib文件夹中。 QT VS工具有一个模块选择工具,但QCharts不包含在这些模块中。无论如何都要手动包含QCharts模块吗?

static string s = @"BEGIN_SECTIONS_INFORMATIONNUMSECTIONS=6SECTION_GROUPNAME[1]=GROUP_1SECTION_NAME[1] = foo\rBEGIN_SECTION[1]\rEND_SECTION[1]\rSECTION_GROUPNAME[2]=GROUP_2SECTION_NAME[2] = bazzzBEGIN_SECTION[2]END_SECTION[2]END_SECTIONS_INFORMATION";


static void Main(string[] args)
{
    var withoutEnd = s.Split(new[] {"END_SECTIONS_INFORMATION"}, StringSplitOptions.RemoveEmptyEntries);
    var SplitItems = withoutEnd[0].Split(new[] { "SECTION_GROUPNAME"}, StringSplitOptions.None).ToList();
    SplitItems.RemoveAt(0); //the first part is just the introduction
    var result = SplitItems.Select(x => "SECTION_GROUPNAME" + x);

}


#include "stdafx.h"
#include "visualization.h"
#include <QChart>
#include <QLineSeries>

QT_CHARTS_USE_NAMESPACE

Visualization::Visualization(QWidget *parent)
    : QWidget(parent)
{
    ui.setupUi(this);
    QLineSeries *series = new QLineSeries();
}

2 个答案:

答案 0 :(得分:1)

解决:我使用VS Qt工具生成了一个新的.pro文件。我修改了这个.pro文件并包含了Qt += charts。然后,我使用更新的.pro文件

重新生成.vcxproj文件

答案 1 :(得分:1)

VS2019遇到了一个类似的问题,该问题无法解决。对于其他遇到此问题的人,对我有用的是在“属性”->“ Qt项目设置”->“ QtModules”中添加“图表”。