简体   繁体   中英

Qt program compiling with MSVC crash on app.exec()

I needed to include OpenCV into my program, so after long time, I gave up to set it up on mingw (which was fully functional for my program) and installed MSVC17 compiler and debugger. But when I run my application with MSVC, program crash with 0x0000005 code, access violation on 0xfffffff .

It always crash on app.exec() in main.cpp

int main(int argc, char *argv[])
{
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    QGuiApplication app(argc, argv);

    MyClass myClass;
    myClass.getView()->setMinimumWidth(900);
    myClass.getView()->setMinimumHeight(600);
    QQuickWindow *quickWindow = qobject_cast<QQuickWindow *>(myClass.getView());
    quickWindow->setFlags(Qt::FramelessWindowHint);

    //Connecting signal from QML to exit application
    QObject::connect(myClass.getView()->engine(), SIGNAL(quit()), &app, SLOT(quit()));

    quickWindow->show();


    return app.exec(); //Here it crash
}

As I said, it fully worked with mingw (32 bit).

Can MSVC2017 x64 somehow crash when building app, that was previously used by mingw x32? Do anyone know how to fix it?

Thank you very much!

//EDIT:

Somehow, it works for release, but not for debug mode.

//EDIT:

It crashes only when app is showing visible QML object

This sounds like a 32 vs. 64-bit issue.

Try updating the dependencies on your item and see if that resolves it, you should be able to re-build the raw source to x64 if you specify that CPU build, and update any dependencies that are x86.

Or, run the app in 32-bit mode.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM