[SOLVED] QGraphicsItem always visible in QGpraphicScene
-
Hi everyone,
I spent two day trying to figure out how to solve my problem but I'm not able to find a solution. I'm sure it is a matter of setting the right property but I do not which I have to modify. I created a simple code to show an image in a QGraphicScene and every time an event happens the image is modified and showed in the scene. At the same time I need to create a Line item and show it in the center of the scene. I did it in this way:
void inspection::on_horizontalSlider_actionTriggered(int action) { int value2 = ui->horizontalSlider->value(); //here I create the transfer_image ui->graphicsView->setScene(scene); QGraphicsPixmapItem* item_pop = new QGraphicsPixmapItem(QPixmap::fromImage(transfer_image)); scene->addItem(item_pop); ui->graphicsView->show(); if (pass ==false) { // if it is the first time I create the line item = new MyItem(); item->setVisible(true); scene->addItem(item); } pass = true; }
My problem is that the first time I enter the function I can see the object but then every time I update the scene I cannot see the line anymore. How can I keep it always on the top of the scene?
thank you
-
I added
item_pop->setPixmap(QPixmap::fromImage(transfer_image));
to update the view and that solved my problem