diff options
author | Itay Grudev <itay@grudev.com> | 2016-08-10 02:43:52 +0100 |
---|---|---|
committer | Itay Grudev <itay@grudev.com> | 2016-08-10 03:43:06 +0100 |
commit | 596cf23bae223d043daf57dcb7b118e149d488e6 (patch) | |
tree | f7ea062970a6fd68a1f245756e5a0ad3d1194f42 /examples/sending_arguments/main.cpp | |
parent | Added a basic usage example (diff) | |
download | singleapplication-596cf23bae223d043daf57dcb7b118e149d488e6.tar.xz |
Added an example of an application sending it's arguments to the primary instance
Diffstat (limited to 'examples/sending_arguments/main.cpp')
-rwxr-xr-x | examples/sending_arguments/main.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/examples/sending_arguments/main.cpp b/examples/sending_arguments/main.cpp new file mode 100755 index 0000000..8368036 --- /dev/null +++ b/examples/sending_arguments/main.cpp @@ -0,0 +1,25 @@ +#include <SingleApplication.h> +#include "messagereceiver.h" + +int main(int argc, char *argv[]) +{ + // Allow secondary instances + SingleApplication app( argc, argv, true ); + + MessageReceiver msgReceiver; + + // If this is a secondary instance + if( app.isSecondary() ) { + app.sendMessage( app.arguments().join(' ').toUtf8() ); + return 0; + } else { + QObject::connect( + &app, + &SingleApplication::receivedMessage, + &msgReceiver, + &MessageReceiver::receivedMessage + ); + } + + return app.exec(); +} |