QtSingleApplication No such file or directory [SOLVED]
I tried to include QtSingleApplication and I got this error: No such file or directory.
QT += core gui widgets
HI and welcome to devnet,
QtSingleApplicationis not part of Qt
@mcosta Thanks, I just realized that. I think that I need to create another one using
if you need to run a single instance of your app you could also use some hidden system file created from you app and deleted when it exit
@mcosta I can't because I want the running instance to receive commands/messages for real-time interaction.
I just created a class that inherits from
QApplicationand created the
QLocalServerthere, my only problem though is to raise/activate/focus/bring to front the window, it doesn't work properly on Windows system.
window->setWindowState(window->windowState() & ~Qt::WindowMinimized); window->raise(); window->activateWindow();
Why not just clone and build QtApplication ? The qt-solutions repository contains it
@SGaist Too much, I looked into the source of the
QtSingleApplicationand it has a lot of deprecated methods, it was easier to create another one.
The functions to raise the window I copied from there, nothing special.
Which version did you got ? I just cloned and built it with Qt 5 without any problem
@SGaist Qt 5.4, but I did my own for other reasons as well, I want to create custom interaction with the running instance and the one that is going to be opened. - For example, if I want to open a new file and one instance is running already, I want to send custom messages to the running instance. I could do that using
QtSingleApplicationfor sure using the method to send messages, but I don't want dependencies.
You embed the code directly in your project if you don't want an additional module to link to
@SGaist It might work, but as I said above, I want to create custom interactions and it's easier that way. - Thank you.