error: LNK2019: unresolved external symbol " [QBarSet] [clean + qmake + rebuild don't fix the problem]



  • note: 
    clean + qmake + rebuild don't fix the problem
    I use msvc2015 32 bits
    

    Hi community,
    I’m trying to create a class to insert a bar chart into MainWindow, but in the moment that I try to use a QBarSet pointer, i obtain from compiler the error below:

    mybars.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QtCharts::QBarSet::QBarSet(class QString,class QObject *)" (__imp_??0QBarSet@QtCharts@@QAE@VQString@@PAVQObject@@@Z) referenced in function "public: __thiscall myBars::myBars(void)" (??0myBars@@QAE@XZ)
    
    mybars.obj:-1: error: LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall myBars::metaObject(void)const " (?metaObject@myBars@@UBEPBUQMetaObject@@XZ)
    
    debug\my_HorBarras_v01.exe:-1: error: LNK1120: 9 unresolved externals
    
    

    Please, could someone explain me why I obtain this issue and how to fix it?
    Thanks in advance

    here are my codes

    mybars.h

    #ifndef MYBARS_H
    #define MYBARS_H
    #include <QtWidgets/QApplication>
    #include <QtWidgets/QMainWindow>
    #include <QtCharts/QChartView>
    #include <QtCharts/QBarSeries>
    #include <QtCharts/QBarSet>
    #include <QtCharts/QLegend>
    #include <QtCharts/QBarCategoryAxis>
    #include <QtCharts/QHorizontalStackedBarSeries>
    
    QT_CHARTS_USE_NAMESPACE
    class myBars
    {
    public:
        myBars();
        ~myBars();
    
    private:
     QBarSet *set0;
    };
    
    #endif // MYBARS_H
    

    mybars.cpp

    #include "mybars.h"
    myBars::myBars()
    {
     set0= new QBarSet("my");
      *set0 << 1 << 10;
    }
    
    myBars::~myBars()
    {
       delete set0;
    }
    

    mainwindow.h

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    #include <mybars.h>
    namespace Ui {
    class MainWindow;
    }
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = nullptr);
        ~MainWindow();
    
    private:
        Ui::MainWindow *ui;
        myBars *bars;
    };
    
    #endif // MAINWINDOW_H
    

    mywindow.cpp

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent), ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
        setFixedSize(1024,768);
        bars = new myBars;
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    
    

  • Moderators

    Do you also link against the QtCharts module? https://doc.qt.io/qt-5.11/qtcharts-index.html



  • Thank you very much!!!
    That was!!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.