I get the following error when I build my application using dynamic linking of Qqcustomplot. If I include qcustomplot.h and cpp no crash occurs.
I don't know where the problem is. In the following there is a test case that derives QCustomplot.
Basically I derived QCustomplot. The plot is added in a QMdiArea as subwindow. When I close the tab, the application crashes if Qcustomplot are linked dynamically.
I'm using QCustomPlot 2.0.0, Qt 5.6.2 and MSVC 2015.
Derived class:
mytabplot.cpp
myTabPlot::myTabPlot(QWidget *parent) : QWidget(parent) { setAttribute(Qt::WA_DeleteOnClose); m_plot = new QCustomPlot(); QGridLayout *plotAreaLayout = new QGridLayout(); plotAreaLayout->addWidget(m_plot); setLayout(plotAreaLayout); }
mytabplot.h
class myTabPlot : public QWidget { Q_OBJECT public: explicit myTabPlot(QWidget *parent = 0); private: QCustomPlot *m_plot; };
This class is then instanted within the mainwindow as follow:
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { m_MdiArea = new QMdiArea(this); m_MdiArea->setViewMode(QMdiArea::TabbedView); m_MdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); m_MdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); m_MdiArea->setTabsClosable(true); setCentralWidget(m_MdiArea); myTabPlot *child = new myTabPlot(); child->setAttribute(Qt::WA_DeleteOnClose); m_MdiArea->addSubWindow(child); connect(m_MdiArea,SIGNAL(subWindowActivated(QMdiSubWindow*)),this,SLOT(setActiveSubWindow(QMdiSubWindow*))); qDebug() << "tab initializedd"; } MainWindow::~MainWindow() { } void MainWindow::setActiveSubWindow(QMdiSubWindow *window) { if (!window) return; m_MdiArea->setActiveSubWindow((window)); }
Someone knows why I getting this crash with dynamic link?