Qt , how to create QApplication without argc and argv

743 views Asked by At

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)

1

There are 1 answers

0
Henrique Bucher On BEST ANSWER

Try this:

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