<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="post-text" itemprop="text">
<p>Hello to all !<br>
</p>
<p>Working on a new QGIS plugin I am trying to connect a custom
function to the mouse right-clic signal, while using the polygon
select maptool.</p>
<p>I have activated the maptool through :</p>
<pre style="" class="lang-py prettyprint prettyprinted"><code><span class="kwd">def</span><span class="pln"> run</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln">
self</span><span class="pun">.</span><span class="pln">iface</span><span class="pun">.</span><span class="pln">actionSelectPolygon</span><span class="pun">().</span><span class="pln">trigger</span><span class="pun">()</span></code></pre>
<p>And would now like to connect my selectSite function to a
canvasReleaseEvent or similar signal. From an interesting
tutorial <a
href="http://www.qgisworkshop.org/html/workshop/plugins_tutorial.html"
rel="nofollow">here</a> I adapted the code and tried the line
below which failed :</p>
<pre style="" class="lang-py prettyprint prettyprinted"><code><span class="kwd">def</span><span class="pln"> run</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln">
self</span><span class="pun">.</span><span class="pln">iface</span><span class="pun">.</span><span class="pln">actionSelectPolygon</span><span class="pun">().</span><span class="pln">trigger</span><span class="pun">()</span><span class="pln">
result </span><span class="pun">=</span><span class="pln"> </span><span class="typ">QObject</span><span class="pun">.</span><span class="pln">connect</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">canvas</span><span class="pun">.</span><span class="pln">mapTool</span><span class="pun">(),</span><span class="pln"> SIGNAL</span><span class="pun">(</span><span class="str">"canvasReleaseEvent()"</span><span class="pun">),</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">selectSite</span><span class="pun">)</span><span class="pln">
</span><span class="kwd">def</span><span class="pln"> selectSite</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln">
</span><span class="typ">QMessageBox</span><span class="pun">.</span><span class="pln">information</span><span class="pun">(</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">iface</span><span class="pun">.</span><span class="pln">mainWindow</span><span class="pun">(),</span><span class="str">"Info"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"in selectSite function"</span><span class="pln"> </span><span class="pun">)</span></code></pre>
<p>Any ideas or hints on how I can achieve my goal ?<br>
</p>
<p>I understand I could reimplement my own polygon selecting tool
and customize it, but it seems like an overkill and am looking
for something simpler - if possible.<br>
Is there another way around by connecting to a more generic Qt
mouse click signal sent by canvas or Qt ?<br>
</p>
<p>Thanks for help.<br>
</p>
<p>Cev.<br>
</p>
<p><br>
</p>
</div>
</body>
</html>