I have a QGraphicsView
in my MainWindow
that I created that in my Ui (of course with the base thread) and I want to set a QGraphicsScene
on it from another thread.
So in constructor of MainWindow
I have:
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
...
connect(this,&MainWindow::graphSceneSignal,this,&MainWindow::graphSceneSlot);
...
QFuture<void> future;
future = QtConcurrent::run(this,&MainWindow::generateGraph);
...
}
and in MainWindow::generateGraph
I have:
void MainWindow::generateGraph()
{
...
QPixmap p("myPix.png");
QGraphicsScene* scene = new QGraphicsScene();
scene->addPixmap(p);
emit graphSceneSignal(scene);
...
}
and in MainWindow::graphSceneSlot
there is:
void MainWindow::graphSceneSlot(QGraphicsScene* scene)
{
ui->graph_graphicsView->setScene(scene);
ui->graph_graphicsView->show();
}
But this warning occurs which I want to solve that:
QObject::killTimer: Timers cannot be stopped from another thread
so how?
UPDATE
I can solve that by moving:
QPixmap p("myPix.png");
QGraphicsScene* scene = new QGraphicsScene();
scene->addPixmap(p);
into MainWindow::graphSceneSlot