Sections

Single Application

The QtSingleApplication component provides support for applications that can be only started once per user.

 

For some applications it is useful or even critical that they are started only once by any user. Future attempts to start the application should activate any already running instance, and possibly perform requested actions, e.g. loading a file, in that instance.

The QtSingleApplication class provides an interface to detect a running instance, and to send command strings to that instance.

On Windows the implementation uses FindWindow() to detect a running instance, and the WM_COPYDATA message to send string data.

On X11 systems the implementation uses X atoms to communicate through the selection mechanism.

On Mac OS X named ports are used both to detect a running instance and to send string data.

 

Documentation:

Classes: Examples:

Tested on:

  • Qt 4.3 / Windows XP / MSVC.NET 2003
  • Qt 4.3 / Windows Vista / MSVC.NET 2005
  • Qt 4.3 / Linux / gcc
  • Qt 4.3 / MacOS X 10.4 / gcc

Unsupported platforms:

Only the tested platforms are supported, however the classes should be platform independent and are likely to work on the platforms supported by Qt.

Download Commercial Edition:

Only available for Qt Solutions license holders with a valid Support and Maintenance agreement (authentication required).

Changes:

  • 2.5: Mac: Fix isRunning() to work and report correctly.
  • 2.4: Fix the system for automatic window raising on message reception. NOTE: minor API change.
  • 2.3: Windows: Force creation of internal widget to make it work with Qt 4.2.
  • 2.2: Mac: Fix memory leak.
  • 2.2: Mac: fix crash due to wrong object releasing.
  • 2.2: Really fix the Mac compilation problem.
  • 2.1: Fix compilation problem on Mac.
  • 2.0: Version 1.3 ported to Qt 4.
Document Actions

Patron of KDECustomers

Customers