QT QCustomPlot in a new thread

匆匆过客 提交于 2019-12-11 14:33:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!