Which Qt signal is triggerred when 2D image is completely updated on QGraphicalScene
-
@saurabh162
It's a bit ugly, but like I said if you don't care the absolute minimum change to just try and see if you get what you want would be:view->view()->setScene(scene); view->view()->repaint(); triggerSignalForScreenShot();
Does that at least do what you want, at least then I understand. Though I still think the
QGraphicsView::render()
call to produce aQImage
would seem to me what you really ought be doing. -
@JonB once again thanks for your response. I have tried following code to do what you suggested
view->view()->setScene(scene); view->show(); QPrinter printer(QPrinter::HighResolution); printer.pageLayout().pageSize(); QPainter painter(&printer); // print, fitting the viewport contents into a full page view->render(&painter); triggerSignalForScreenShot();
but still I getting the result/problem as mentioned above.
triggerSignalForScreenShot()
is user defined signal which I connect to its slot using :
connect(this,&MainWindow::triggerSignalForScreenShot, this, &MainWindow::sceneChanged);
and slot I defined as follows:
void MainWindow::sceneChanged( ) { shootScreen(); saveScreenshot(); }
Thanks !! and kindly inform me if you need any other information or if I am making any mistake.
-
@saurabh162 said in Which Qt signal is triggerred when 2D image is completely updated on QGraphicalScene:
view->render(&painter);
triggerSignalForScreenShot();As per the docs this renders the view into the
painter
you pass torender()
, from which it says you can produce aQImage
. I have no idea what you think you are doing by ignoring this and calling your originaltriggerSignalForScreenShot()
, what does that have to do with it?I also suggested you try the simplest current "fix" by putting in a
view->view()->repaint();
initially and seeing that delivers what you want, but you don't seem to have looked at that.I leave it to you now, I have helped all I can.
-
@JonB Thank you !! Actually I have tried view->view()->repaint(); solution provided by you. but it did not help and after that I have tried solution I have pasted in my previous post.
And about " triggerSignalForScreenShot()" signal I have used because I did not understand how I can pass QImage to render() so that it produce image of screen(Sorry I am newbie in Qt).
But many thanks for your help ..I will now try/see how i can pass QImage object in render() function. Thank you !!
-
I am still curious about your need to do the capture of the shown image for comparison rather that do the comparison directly with the image you rebuilt from the camera data.
-
@JonB @ChrisW67 @SGaist ...I am now able to save snapshot of image I display using "QGraphicsScene" using method mentioned by @JonB .
In order to save image in .png format. i have used following code.
// Save rendered image in a .png file
```
QImage image(11000,7000, QImage::Format_RGB32);
QPainter painter(&image); scene->render(&painter); painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); image.mirrored().save("output.png");
many thanks for your help !!
-
@saurabh162 said in Which Qt signal is triggerred when 2D image is completely updated on QGraphicalScene:
@SGaist sorry I could not understand your question....whether you want to ask, why I want to capture image using camera ? instead of directly comparing images with my reference images directly ?
No no, I am wondering about the "capture the scene" step rather than directly save the built image.
-
@SGaist Capturing image(pattern provided by DMDs(Digital micromirror device)) is important in our case to adjust output from DMDs ( feedback loop ) which will be connected to camera responsible to take pictures on screen.
We cannot give feedback to DMDs directly from our PC due to technical reasons...please inform me if i have not answered your question....Thanks !!
-
You are at the wrong end of the system for my question.
I have no issue with the act of capturing that image for your feedback loop. My question is really, why do need to the detour through the painting of the QGraphicsScene rather than simply save the image you built from the camera to disk ? That would likely give you a higher quality image.