I'm making a program that calculates a bunch of values based on user inputs and it's supposed to ouput a bar chart on those inputs. Initially my values were stored in QVectors, and the QBarSet class append()
function only worked with QLists. After changing all the QVectors to QLists and fixing the append()
error, i was met with 58 errors all being a variant of:
error: undefined reference to `_imp___ZN8QtCharts*'
the asterik indicating a number of different errors.
sixthpage.cpp
#include "sixthpage.h"
#include "ui_sixthpage.h"
#include "fifthpage.h"
#include "thirdpage.h"
#include "fourthpage.h"
#include <QtWidgets/QApplication>
#include <QtWidgets/QMainWindow>
#include <QtCharts/QChartView>
#include <QtCharts/QBarSeries>
#include <QtCharts/QBarSet>
#include <QtCharts/QLegend>
#include <QtCharts/QBarCategoryAxis>
#include <QList>
using namespace QtCharts;
sixthpage::sixthpage(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::sixthpage)
{
ui->setupUi(this);
showMaximized();
FifthPage *fifthpage = new FifthPage();
ThirdPage *thirdpage = new ThirdPage();
FourthPage *fourthpage = new FourthPage();
QObject::connect(thirdpage,SIGNAL(economicData(QList<double>,QList<double>)),this, SLOT(showEconomicGraph(QList<double> normalizedKPI,QList<double> maxNormalizedKPI)));
QObject::connect(fourthpage,SIGNAL(enviornmentlaData(QList<double>,QList<double>)),this, SLOT(showEnviornmentalGraph(QList<double> normalizedKPI,QList<double> maxNormalizedKPI)));
QObject::connect(fifthpage,SIGNAL(socialData(QList<double>,QList<double>)),this, SLOT(showSocialGraph(QList<double> normalizedKPI,QList<double> maxNormalizedKPI)));
}
sixthpage::~sixthpage()
{
delete ui;
}
void sixthpage::on_showGraph_clicked(QList<double> normalizedKPI, QList<double> maxNormalizedKPI)
{
if(ui->radioButton->isCheckable())
{
showEconomicGraph(normalizedKPI, maxNormalizedKPI);
}
if(ui->radioButton_2->isCheckable())
{
showEnviornmentalGraph(normalizedKPI, maxNormalizedKPI);
}
if(ui->radioButton_3->isCheckable())
{
showSocialGraph(normalizedKPI, maxNormalizedKPI);
}
}
void sixthpage::showEconomicGraph(QList<double> normalizedKPI, QList<double> maxNormalizedKPI){
//int size = normalizedKPI.length();
QBarSet *set0 = new QBarSet("Normalized KPI Achievement");
QBarSet *set1 = new QBarSet("Max. Normalized KPI Achievement");
set0->append(normalizedKPI);
set1->append(maxNormalizedKPI);
QBarSeries *series = new QBarSeries();
series->append(set0);
series->append(set1);
QChart *chart = new QChart();
chart->addSeries(series);
chart->setTitle("Economic Sustainability");
chart->setAnimationOptions(QChart::SeriesAnimations);
QStringList categories;
categories << "X1" << "X2" << "X3" << "X4" << "X5" << "X6" << "X7" << "X8" << "X9" << "X10" << "X11" << "X12" << "X13" << "X14";
QBarCategoryAxis *axis = new QBarCategoryAxis();
axis->append(categories);
chart->createDefaultAxes();
chart->setAxisX(axis, series);
chart->legend()->setVisible(true);
chart->legend()->setAlignment(Qt::AlignBottom);
QChartView *chartView = new QChartView(chart);
chartView->setRenderHint(QPainter::Antialiasing);
}
void sixthpage::showEnviornmentalGraph(QList<double> normalizedKPI, QList<double> maxNormalizedKPI){
// int size = normalizedKPI.length();
QBarSet *set0 = new QBarSet("Normalized KPI Achievement");
QBarSet *set1 = new QBarSet("Max. Normalized KPI Achievement");
set0->append(normalizedKPI);
set1->append(maxNormalizedKPI);
QBarSeries *series = new QBarSeries();
series->append(set0);
series->append(set1);
QChart *chart = new QChart();
chart->addSeries(series);
chart->setTitle("Enviornmental Sustainability");
chart->setAnimationOptions(QChart::SeriesAnimations);
QStringList categories;
categories << "X15" << "X16" << "X17" << "X18" << "X19" << "X20" << "X21" << "X22" << "X23" << "X24" << "X25";
QBarCategoryAxis *axis = new QBarCategoryAxis();
axis->append(categories);
chart->createDefaultAxes();
chart->setAxisX(axis, series);
chart->legend()->setVisible(true);
chart->legend()->setAlignment(Qt::AlignBottom);
QChartView *chartView = new QChartView(chart);
chartView->setRenderHint(QPainter::Antialiasing);
}
void sixthpage::showSocialGraph(QList<double> normalizedKPI, QList<double> maxNormalizedKPI){
// int size = normalizedKPI.length();
QBarSet *set0 = new QBarSet("Normalized KPI Achievement");
QBarSet *set1 = new QBarSet("Max. Normalized KPI Achievement");
set0->append(normalizedKPI);
set1->append(maxNormalizedKPI);
QBarSeries *series = new QBarSeries();
series->append(set0);
series->append(set1);
QChart *chart = new QChart();
chart->addSeries(series);
chart->setTitle("Social Sustainability");
chart->setAnimationOptions(QChart::SeriesAnimations);
QStringList categories;
categories << "X26" << "X27" << "X28" << "X29" << "X30" << "X31" << "X32" << "X33" << "X34" << "X35" << "X36" << "X37";
QBarCategoryAxis *axis = new QBarCategoryAxis();
axis->append(categories);
chart->createDefaultAxes();
chart->setAxisX(axis, series);
chart->legend()->setVisible(true);
chart->legend()->setAlignment(Qt::AlignBottom);
QChartView *chartView = new QChartView(chart);
chartView->setRenderHint(QPainter::Antialiasing);
}
If someone could please tell me how to get rid of the undefined reference errors, I'd be very grateful. Also feel free to point out any other visible errors. I'm pretty new to QT so i'm having quite the hard time getting things done.
EDIT
This link was labeled as a possible duplicate but it explains the general error of linking problems, which i already understand. What I want is for someone to explain how my errors specific to QtCharts can be resolved. I've added all the necessary files the documentation shows as well.