axeoth
1st April 2012, 20:45
Dear all,
I am really new at Qt, but I have a bit of experience with C (mostly) and with C++ (a bit).
I have the folowing situation: a C application that periodically calls a processing function, let's say process() with some input data. Now, inside this process() function, I receive the input data (an RGB pixel buffer) and I want to display it in a QT GUI, through something like:
QLabel myLabel;
myLabel.setPixmap(QPixmap::fromImage(myImage));
myLabel.show();
(this is the simplest way to display an image that I found).
Now, I know how to build a QImage object (the above myImage) from that input data that comes to process(). But how to display all that in a QT QUI *without* blocking the process() function with an app.exec()?
The solution that I implemented is to launch a separate thread (with pthread_create()) in the init part of my application, and in that thread to create a QApplication and the GUI displaying the QLabel myLabel object. Then, that thread can run app.exec() without blocking my process() function.
But, the big question is now: how to convince my QLabel to update itself with the new image generated from the data that I receive with each call of process()?
Thank you.
I am really new at Qt, but I have a bit of experience with C (mostly) and with C++ (a bit).
I have the folowing situation: a C application that periodically calls a processing function, let's say process() with some input data. Now, inside this process() function, I receive the input data (an RGB pixel buffer) and I want to display it in a QT GUI, through something like:
QLabel myLabel;
myLabel.setPixmap(QPixmap::fromImage(myImage));
myLabel.show();
(this is the simplest way to display an image that I found).
Now, I know how to build a QImage object (the above myImage) from that input data that comes to process(). But how to display all that in a QT QUI *without* blocking the process() function with an app.exec()?
The solution that I implemented is to launch a separate thread (with pthread_create()) in the init part of my application, and in that thread to create a QApplication and the GUI displaying the QLabel myLabel object. Then, that thread can run app.exec() without blocking my process() function.
But, the big question is now: how to convince my QLabel to update itself with the new image generated from the data that I receive with each call of process()?
Thank you.