refresh image in a Qlabel
I have set an image using Qlabel as:
Code:
ui
->label
->setPixmap
(QPixmap("/home/hls/Grab-build-desktop-Qt_4_8_1_in_PATH__System__Debug/rgb.bmp"));
I am performing some image processing tasks,so I want to refresh my image continuously.
Currently it is showing the image which appears at the start of the application.
The application changes the image,and I want to change the image continuously in the label
How can i Do that?
Re: refresh image in a Qlabel
Make QPixmap as class member and reset image QLabel::setPixmap when the image has been changed.
Re: refresh image in a Qlabel
I am sorry,but couldn't understand by "Make QPixmap as class member".
I have now reset the image everytime after the image has changed.
It's only a temporary fix.
Isn't there anything where I only have to give the refernce of the file and the QLabel changes automatically whenever the picture changes.
Re: refresh image in a Qlabel
Quote:
Originally Posted by prkhr4u
I am sorry,but couldn't understand by "Make QPixmap as class member".
Declare QPixmap it in the header file as a private or public... member and initialize or define it in your .cpp file then you might be able to find an approach to solve your problem.
Good Luck.
Re: refresh image in a Qlabel
Quote:
Originally Posted by
prkhr4u
Isn't there anything where I only have to give the refernce of the file and the QLabel changes automatically whenever the picture changes.
No, there is not anything something like this. QLabel doesn't keep track of QPixmap changes, you have to reset the pixmap each time it has been changed in order to make correct rendering by QLabel.
Re: refresh image in a Qlabel
Quote:
Originally Posted by
prkhr4u
I am performing some image processing tasks,so I want to refresh my image continuously.
Do you perform those processing steps outside the displaying application?
Cheers,
_
Re: refresh image in a Qlabel
No,the processing is performed in a seperate thread,but in the same application
Re: refresh image in a Qlabel
Then you could just set the updated image on the label whenever your thread has signalled that it is finished.
No need to go through saving/loading a file, just creating a QPixmap from the QImage you are working on.
Cheers,
_
Re: refresh image in a Qlabel
Have done something similar, reset the image everytime the processing completes.
But as the application is continuous running, the thread never finishes..but only on application exit.
Re: refresh image in a Qlabel
Quote:
Originally Posted by
prkhr4u
But as the application is continuous running, the thread never finishes..but only on application exit.
If its a worker thread then you are doing something wrong and you have to go over the thread class and the threads object creation to figure it out.
When the Process that the thread is responsible for is done, delete the threads object and catch the threads finish signal.(you can emit your own finish signal).
Good Luck.
Re: refresh image in a Qlabel
Quote:
Originally Posted by
prkhr4u
Have done something similar, reset the image everytime the processing completes.
But as the application is continuous running, the thread never finishes..but only on application exit.
How is that related to your goal of updating the image?
Does your thread never finish processing the image?
Cheers,
_
Re: refresh image in a Qlabel
I have one GUI thread and one worker thread. Whenever I signal 'start' from GUI thread the processing starts in worker thread and whenever I signal 'stop' the processing in worker thread stops.
After signalling 'stop' the image has to be refreshed in the GUI,
But the image processing code of start and stop code has been enclosed in a while(1) loop,hence the thread never exits..but only on the application exit.
I need to process the image every 2-3 seconds,hence i have let the thread run thorughout the application.
Re: refresh image in a Qlabel
Ok, but that has no relation to the image processing being done at some point, i.e. when you signal stop.
The thread stops accessing the image and you use it to update the label.
Cheers,
_