可以达到的目的:
1、应用只启动一个实例,依赖于QtNetwork模块
2、启动时向另一个实例通信
下载地址:http://qt.gitorious.org/qt-solutions/qt-solutions/archive-tarball/master
解压开后,将里面的qtsingleapplication目录拷贝到项目的源码目录中,然后修改项目的.pro文件,加入下面一行代码
- include(../qtsingleapplication/src/qtsingleapplication.pri)
修改main.cpp文件,加入头文件
- #include <QtSingleApplication>
main函数实现:
- QtSingleApplication app(argc, argv);
if (app.isRunning())
{
app.sendMessage("raies");
return EXIT_SUCCESS;
}
........
QMainWindow w;
app.setActivationWindow(&w);
.......
From: http://qtcn.org/bbs/apps.php?q=diary&uid=2&a=detail&did=122
@import url(http://www.cppblog.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);