From 596cf23bae223d043daf57dcb7b118e149d488e6 Mon Sep 17 00:00:00 2001 From: Itay Grudev Date: Wed, 10 Aug 2016 02:43:52 +0100 Subject: Added an example of an application sending it's arguments to the primary instance --- examples/sending_arguments/main.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 examples/sending_arguments/main.cpp (limited to 'examples/sending_arguments/main.cpp') 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 +#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(); +} -- cgit v1.2.1