Maleev
Maleev

Reputation: 863

Simple inter-proccess communication in Qt4

I need to make so that my application can have only one instance running at a time. Also when it's launched with a command line parameter ( like when registered to open certain file types ) it should pass the parameter to an existing instance and quit immediately without displaying graphical interface. You all probably know what I mean. The framework used is Qt 4, and it seems like it must have some facilities for that. Any ideas?

Upvotes: 2

Views: 1016

Answers (3)

Max Kueng
Max Kueng

Reputation:

There are several ways to do inter process communication. Examples can be found in Qt's examples section.

Upvotes: 1

Maleev
Maleev

Reputation: 863

It's also possible to implement a this sort of class oneself using QSharedMemory (see QSharedMemory::attach() ). It's capable of being used for both determining whether other instance is already running and communicating/sending messages. Except some pointer magic and memory copying it's quite straightforward.

Upvotes: 0

ashcatch
ashcatch

Reputation: 2367

There is a Qt Solutions project doing this:

Qt Single Application

Upvotes: 3

Related Questions