Now, I have 1 application, but I don\'t want to open application twice, so I using QShareMemory
to detect application when open twice.
And my question is: how I
Just use QSingleApplication
class instead of QApplication
:
https://github.com/qtproject/qt-solutions/tree/master/qtsingleapplication
int main(int argc, char **argv)
{
QtSingleApplication app(argc, argv);
if (app.isRunning())
return 0;
MyMainWidget mmw;
app.setActivationWindow(&mmw);
mmw.show();
return app.exec();
}
It is part of Qt Solutions: https://github.com/qtproject/qt-solutions