Qt World Summit: Submit your Presentation

adding openCV Video to QT Widget

  • Hey Folks,

    Having a bit of an issue getting a video to display in a QT Widget.

    I can get an openCV window to run/function and display video from my webcam just fine,but when I execute a program the openCV window is the only part the will open until I terminate the webcam loop. Once the webcam is disabled my QT GUI will pop up like normal.

    Below is a copy of my VideoCapture example and a part of my MainWindow Class.

    void VideoHeader::videoCap()
        Mat frame;
        VideoCapture cap;
            cerr << "ERROR! Unable to open camera\n";
        cout << "Start grabbing" << endl;
                cerr << "ERROR! Blank frame grabbed\n";
            //imshow("Live", frame);
            if(waitKey(5) >= 0)

    MainWindow::MainWindow() : textEdit(new QTextEdit)

    VideoHeader newVideo;


  • Lifetime Qt Champion


    That's because you are creating an infinite loop that doesn't let Qt's event loop run.

    This post describes an interesting way of using OpenCV capture with a Qt GUI.

    Hope it helps

  • Thanks for the response! That link has lead me down the right path I believe. Using QThread to run the VideoCapture function portion and it appears to be working somewhat properly now.

  • Lifetime Qt Champion

    Great !

    Since you have it working now, please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found :)

Log in to reply