<p>The application in this example has a log-view that displays messages sent by further instances of the same application.</p>
<p>The example demonstrates the use of the <ahref="qtsingleapplication.html">QtSingleApplication</a> 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 <ahref="http://qt.nokia.com/doc/4.6/qtextedit.html">QTextEdit</a> log.</p>
<p>The example has only the <tt>main</tt> entry point function. A <ahref="qtsingleapplication.html">QtSingleApplication</a> object is created immediately.</p>
<pre> if (instance.sendMessage("Wake up!"))
return 0;</pre>
<p>If another instance of this application is already running, sendMessage() will succeed, and this instance just exits immediately.</p>
<pre> TextEdit logview;
logview.setReadOnly(true);
logview.show();</pre>
<p>Otherwise the instance continues as normal and creates the user interface.</p>
<p>The <tt>logview</tt> object is also set as the application's activation window. Every time a message is received, the window will be raised and activated automatically.</p>
<p>The messageReceived() signal is also connected to the <ahref="http://qt.nokia.com/doc/4.6/qtextedit.html">QTextEdit</a>'s append() slot. Every message received from further instances of this application will be displayed in the log.</p>