Ask Your Question

Revision history [back]

QT Gui Application crashed

Hi, I'm sorry - my english is bad.

I'm write simple Qt application with opencv:

#include "mainwindow.h"
#include <QApplication>
#include <iostream>
int main(int argc, char *argv[]){
    QApplication a(argc, argv);
    MainWindow w;
    w.show();
    w.ViewShootCam();
    return a.exec();
}
.....
void MainWindow::ViewShootCam(){
    cv::Mat img;
    cv::VideoCapture cap;

    if( ! cap.isOpened() ){
        qDebug()<<"not captured!";
        return;
    }
    cap >> img;

    cv::cvtColor(img, img, CV_BGR2RGB);
    QImage out_img((const unsigned char*)(img.data), img.cols, img.rows, QImage::Format_RGB888);
    QLabel* lbl=ui->m_img_lbl;
    lbl->setPixmap(QPixmap::fromImage(out_img));
    lbl->show();
}

And I have strength bug: while the code is opentсv calls - my application crushed without debugging. My app is closed after start and return code is -1073741515. Even if I do not use MainWindow::ViewShootCam(), application is crushed too. I try to use MSVC 2010, mingw32 compillers for Win7, Qt 4.8.4 and different builds of opencv(2.4.4, 2.4.3, 2.3.1) with Qt support and without Qt Support.