问题
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?
来源:https://stackoverflow.com/questions/48337058/qt-qcustomplot-in-a-new-thread