<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi,<div class=""><br class=""></div><div class="">I’m toying with QtQuick and QML for a few days and found that the reason is always 3 no matter how I click the icon in the following code;</div><div class=""><br class=""></div><div class="">
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><!--StartFragment--><span style=" color:#808000;" class="">import</span><span style=" color:#c0c0c0;" class=""> </span>QtQuick<span style=" color:#c0c0c0;" class=""> </span>2.9</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#808000;" class="">import</span><span style=" color:#c0c0c0;" class=""> </span>QtQuick.Controls<span style=" color:#c0c0c0;" class=""> </span>2.2</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#808000;" class="">import</span><span style=" color:#c0c0c0;" class=""> </span>QtQuick.Window<span style=" color:#c0c0c0;" class=""> </span>2.2</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#808000;" class="">import</span><span style=" color:#c0c0c0;" class=""> </span>Qt.labs.platform<span style=" color:#c0c0c0;" class=""> </span>1.0</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#800080;" class="">Window</span><span style=" color:#c0c0c0;" class=""> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">    </span><span style=" color:#800000;" class="">id</span>:<span style=" color:#c0c0c0;" class=""> </span><span style="font-style: italic;" class="">root</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">    </span><span style=" color:#800000;" class="">visible</span>:<span style=" color:#c0c0c0;" class=""> </span>true</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">    </span><span style=" color:#800000;" class="">width</span>:<span style=" color:#c0c0c0;" class=""> </span>640</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">    </span><span style=" color:#800000;" class="">height</span>:<span style=" color:#c0c0c0;" class=""> </span>480</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">    </span><span style=" color:#800000;" class="">title</span>:<span style=" color:#c0c0c0;" class=""> </span><span style=" font-style:italic; color:#0055af;" class="">qsTr</span>(<span style=" color:#008000;" class="">"Hello</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">World"</span>)</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">    </span><span style=" color:#800080;" class="">SystemTrayIcon</span><span style=" color:#c0c0c0;" class=""> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">        </span><span style=" color:#800000;" class="">id</span>:<span style=" color:#c0c0c0;" class=""> </span><span style="font-style: italic;" class="">trayIcon</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">        </span><span style=" color:#800000;" class="">visible</span>:<span style=" color:#c0c0c0;" class=""> </span>true</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">        </span><span style=" color:#800000;" class="">iconSource</span>:<span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">"qrc:/icon.png"</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">        </span><span style=" color:#800000;" class="">onActivated</span>:<span style=" color:#c0c0c0;" class=""> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">            </span><span style=" font-style:italic; color:#0055af;" class="">console</span>.log(<span style=" color:#008000;" class="">"reason:</span><span style=" color:#c0c0c0;" class=""> </span><span style=" color:#008000;" class="">"</span><span style=" color:#c0c0c0;" class=""> </span>+<span style=" color:#c0c0c0;" class=""> </span><span style=" font-style:italic; color:#2985c7;" class="">reason</span>)</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">            </span><span style=" color:#808000;" class="">if</span>(<span style=" font-style:italic; color:#2985c7;" class="">reason</span><span style=" color:#c0c0c0;" class=""> </span>===<span style=" color:#c0c0c0;" class=""> </span>1){</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">                </span><span style="font-style: italic;" class="">trayMenu</span>.open()</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">            </span>}<span style=" color:#c0c0c0;" class=""> </span><span style=" color:#808000;" class="">else</span><span style=" color:#c0c0c0;" class=""> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">                </span><span style=" color:#808000;" class="">if</span>(<span style="font-style: italic;" class="">root</span>.visibility<span style=" color:#c0c0c0;" class=""> </span>===<span style=" color:#c0c0c0;" class=""> </span><span style=" color:#800080;" class="">Window</span>.Hidden){</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">                    </span><span style="font-style: italic;" class="">root</span>.show()</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">                    </span><span style="font-style: italic;" class="">root</span>.raise()</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">                    </span><span style="font-style: italic;" class="">root</span>.requestActivate()</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">                </span>}<span style=" color:#c0c0c0;" class=""> </span><span style=" color:#808000;" class="">else</span><span style=" color:#c0c0c0;" class=""> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">                    </span><span style="font-style: italic;" class="">root</span>.hide()</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">                </span>}</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">            </span>}</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">        </span>}</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">    </span>}</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">    </span><span style=" color:#800080;" class="">Menu</span><span style=" color:#c0c0c0;" class=""> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">        </span><span style=" color:#800000;" class="">id</span>:<span style="font-style: italic;" class="">trayMenu</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">        </span><span style=" color:#800000;" class="">enabled</span>:<span style=" color:#c0c0c0;" class=""> </span>true</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">        </span><span style=" color:#800080;" class="">MenuItem</span><span style=" color:#c0c0c0;" class=""> </span>{</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">            </span><span style=" color:#800000;" class="">text</span>:<span style=" color:#c0c0c0;" class=""> </span><span style=" font-style:italic; color:#0055af;" class="">qsTr</span>(<span style=" color:#008000;" class="">"Quit"</span>)</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">            </span><span style=" color:#800000;" class="">onTriggered</span>:<span style=" color:#c0c0c0;" class=""> </span><span style=" font-style:italic; color:#0055af;" class="">Qt</span>.quit()</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">        </span>}</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">    </span>}</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;" class="">}<!--EndFragment--></pre><div class=""><br class=""></div></div><div class="">is there a way to fix this? (trying on macos but want it to work cross platform eventually)</div><div class=""><br class=""></div><div class="">Regards,</div><div class=""><br class=""></div><div class="">Emre Besirik</div></body></html>