Home > Net >  Qt , how to create QApplication without argc and argv
Qt , how to create QApplication without argc and argv

Time:08-15

Hey so I need to export a qt application as a .dll and , so I dont want any arguments like argc and argv , but QApplication needs them , so i tried this

int main()
{
    int c=1;
    char** v = (char**)("ApplicationName");
    QApplication app(c,v);
    MainWindow window;
    window.show();
    return app.exec();
}

but I get segfault from QtCore... Can someone help me bypass the segfault and create the QApplication without needing argc and argv? This didnt solve the problem cause it needs argv defined ... QApplication app(argc, argv)

CodePudding user response:

Try this:

int main()
{
    char* args[] = { (char*)"AppName" };
    QApplication app(1,args);
    MainWindow window;
    window.show();
    return app.exec();
}
  • Related