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?