How can i prevent my app open multiple times with Qt?
-
[quote author="Vass" date="1315747553"]Try QtSingleApplication - it's right way :)
Link to repo: http://qt.gitorious.org/qt-solutions/qt-solutions[/quote]
Can u tell me. From all the files that are in qtsingleapplication.pro project which one should i see?
-
[quote author="Vass" date="1315761368"]Open INSTALL.TXT file, and read how you can build QtSingleApplication as Shared Library. after you would do it, you can use QtSingleApplication Library in you program. See examples in examples directory.[/quote]
Can't install it.. It keeps saying the same message:
!http://img690.imageshack.us/img690/4669/screenshotqtsingleappli.png(screen)! -
Have you tried to run qmake and make commands? :)
-
Why do you run configure as last element? It should be executed first.
-
Ok so here is the complete outpout of ./configure -> qmake -> make ( http://paste.ubuntu.com/688207/ )
After doing that i am including QtSingleApplication at my app and it says QtSingleApplication is not declared. -
The usual way is to add the path to the include path in your project file.
@
INCLUDEPATH += <location_of_qtsingleapplication_headers>
@
In addition, the QtSingleApplication libraries have to be added too.
@
LIBS += -L<location_of_qtsingleapplication_libraries>
LIBS += -l<name_of_qtsingleapplication_library>
@
And - of course - you will have to include the headers in your sources files too.
@
#include <QtSingleApplication>
@ -
So whats wrong with that:
@INCLUDEPATH += <~/Downloads/qt-solutions-qt-solutions/qtsingleapplication/src>
LIBS += -L<~/Downloads/qt-solutions-qt-solutions/qtsingleapplication/src>
LIBS += -l<~/Downloads/qt-solutions-qt-solutions/qtsingleapplication/src/qtsinglecoreapplication.h>@
? -
Forgot.
@INCLUDEPATH += ~/Downloads/qt-solutions-qt-solutions/qtsingleapplication/src
LIBS += -L~/Downloads/qt-solutions-qt-solutions/qtsingleapplication/src
LIBS += -l~/Downloads/qt-solutions-qt-solutions/qtsingleapplication/src/qtsinglecoreapplication.h@But still i cant
@#include <QtSingleApplication>@
at my cpp file.P.S Should it have a spece between -l and ~ symbol.?
-
There are two ways on how to use QtSingleApplication:
- You add the sources directly to your project or
- You compile QtSingleApplication into a library and your application links against this library
#1 requires you to add all of the QtSingleApplication sources to your application. The easiest way to do is including the qtsingleapplication.pri from the src directory.
@
// .pro
include(../qtsingleapplication/src/qtsingleapplication.pri)
@#2 requires you to build the library first
@
// shell
./configure -library
qmake
make
@
and then reference it in your project file
@
// .pro
INCLUDEPATH += ../qtsingleapplication/src
LIBS += -L../qtsingleapplication/lib
LIBS += -lQtSolutions_SingleApplication-head
@ -
How should it be with the first way?
@include(~/Downloads/qt-solutions-qt-solutions/qtsingleapplication/src/qtsingleapplication.pri)
@
?P.S All this sounds a bit complicated, and if someone wants to compile my app they must download qtsingleapplication librarie. Should i stay with the command pidof or QtSingleApplication will be better?