summaryrefslogtreecommitdiffstats
path: root/qtsingleapplication/examples/trivial/trivial.qdoc
blob: 4a8640ebd04fcf5470825149e30efc5195dad494 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
// SPDX-License-Identifier: BSD-3-Clause

/*! \page qtsingleapplication-example-trivial.html
    \title A Trivial Example

    The application in this example has a log-view that displays
    messages sent by further instances of the same application.

    The example demonstrates the use of the QtSingleApplication
    class to detect and communicate with a running instance of
    the application using the sendMessage() API. The messageReceived()
    signal is used to display received messages in a QTextEdit log.

    \quotefromfile trivial/main.cpp
    \printuntil instance
    The example has only the \c main entry point function.
    A QtSingleApplication object is created immediately.

    \printuntil return 
    If another instance of this application is already running,
    sendMessage() will succeed, and this instance just exits
    immediately.

    \printuntil show()
    Otherwise the instance continues as normal and creates the
    user interface.

    \printuntil return instance.exec();
    The \c logview object is also set as the application's activation
    window. Every time a message is received, the window will be raised
    and activated automatically.

    The messageReceived() signal is also connected to the QTextEdit's
    append() slot. Every message received from further instances of
    this application will be displayed in the log.

    Finally the event loop is entered.
*/