QT QCustomPlot in a new thread

2019-08-31 06:02发布

In my UI, I have a QCustomPlot and I have generatePlot function which uses from this QCustomPlot and runs in a new thread as follows:

future = QtConcurrent::run(this, &MainWindow::generatePlot);

In generatePlot function, I create QCPbars like this:

QCPBars *bar = new QCPBars(customPlot->xAxis, customPlot->yAxis);

But, I get this error:

QObject: Cannot create children for a parent that is in a different thread.

I think that's because the thread of customPlot is diffrenet from bar. How can I solve it?

0条回答
登录 后发表回答