Created
September 8, 2017 12:12
-
-
Save j2doll/cea87c07ac2b4574617329a8f6c50cf1 to your computer and use it in GitHub Desktop.
single instance process for Qt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // qt.single.instance.cpp | |
| // | |
| // code from http://blog.naver.com/PostView.nhn?blogId=browniz1004&logNo=220957590867&categoryNo=15&parentCategoryNo=0&viewDate=¤tPage=8&postListTopCurrentPage=&from=postList&userTopListOpen=true&userTopListCount=5&userTopListManageOpen=false&userTopListCurrentPage=8 | |
| #include "mainwindow.h" | |
| #include <QApplication> | |
| #include <QSharedMemory> | |
| int main(int argc, char *argv[]) | |
| { | |
| QApplication a(argc, argv); | |
| MainWindow w; | |
| QSharedMemory shared("HelloWorld"); | |
| if(!shared.create(512,QSharedMemory::ReadWrite)) | |
| { | |
| QMessageBox::information(&w,QObject::tr("HelloWorld"),QObject::tr("It's already running"),QMessageBox::Ok); | |
| exit(0); | |
| } | |
| w.show(); | |
| return a.exec(); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment