I have used the example (commonly known) of using a QLabel to display image data that I'm pulling off of a camera. The relevant code is below :
void myGUI::updatePic1(imgStructColorQt image)
{
QImage img((const uchar*)image.data,BUFFER_XSIZE,BUFFER_YSIZE, COLOR_BUFFER_BYTE_SIZE*BUFFER_XSIZE, QImage::Format_RGB32);
img = img.scaled(514,388);
if (!img.isNull())
{
ui->cam1view->setPixmap(QPixmap::fromImage(img));
ui->cam1view->update();
ui->cam1view->repaint();
std::cout << "image updated!" << std::endl;
}
else
std::cout << "image is null" << std::endl;
}
Where updatePic1
is a slot called about 30 times a second with updated image data. My QLabel, cam1view, on my main GUI window displays the first image, but never updates after that. I know that the slot is being called correctly as I see the console output displaying "image updated!" about 30 times a second. Does anyone have any suggestions as to why the QLabel is not being updated? I also know that the image data is actually changing, because I can print single pixels to the screen and observe that they are changing as I would expect when I take off and put on a lens cap.