1

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.

4

1 回答 1

0

哪个线程在调用这个槽?

请记住,如果发出信号的 QObject 和接收信号的 QObject 存在于同一个线程中,那么连接将是直接的,而不是使用事件队列进行调度。

可能是您的事件线程是处理包含发出的循环的线程。在这种情况下,您的应用程序将永远不会更新 GUI,因为它被锁定处理您的循环。

您是否在单独的线程中进行帧采集?

于 2013-06-26T19:36:51.870 回答