提供了对一段共享内存的访问。既提供了被多进程和多线程共享的一段内存的访问。也为单线程或单进程锁定内存以实现互斥访问提供了方法。
QSharedMemory shared("cfg");
if(shared.attach())//共享内存被占用则直接返回
{
QMessageBox::information(NULL, QStringLiteral("Warning"), QStringLiteral("Application is alreadly running!"));
return 0;
}
shared.create(1);//共享内存没有被占用则创建UI
http://www.itcast.cn/news/20180105/11101295013.shtml
https://blog.csdn.net/xiaomucgwlmx/article/details/82691612
原文:https://www.cnblogs.com/guapilsh/p/14439973.html