Hi,<br><br>I'm currently trying to overload the canvasPressEvent from QgsMapTool in my plugin but it doesn't work, did i forgot anything in my code??&nbsp; I put a message box when the mouse is clicked on the canvas but I never get the message.&nbsp; Is it the constructor and i don't initialize the QgsMapTool correctly??
<br><br>/***************** plugin.h<br><br>[...]<br>#include &lt;qgsmaptool.h&gt;<br>[...]<br>class plugin : public QObject, public QgisPlugin, public QgsMapTool {<br>&nbsp;&nbsp;&nbsp; Q_OBJECT;<br>&nbsp;&nbsp;&nbsp; public:<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; virtual ~plugin();
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; plugin(QgisApp * theApplication, QgisIface * theInterface);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; virtual void canvasPressEvent(QMouseEvent * e);<br>&nbsp;&nbsp;&nbsp; public slots:<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; [...]<br>&nbsp;&nbsp;&nbsp; private:<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; [...]<br><br>/***************** 
plugin.cpp<br><br>[...]<br>#include &quot;plugin.h&quot;<br>QGISEXTERN QgisPlugin * classFactory(QgisApp * theQGisAppPointer, QgisIface * theQgisInterfacePointer) {<br>&nbsp;&nbsp;&nbsp; return new plugin(theQGisAppPointer, theQgisInterfacePointer);
<br>}<br>[...]<br>plugin::plugin(QgisApp * theQGisApp, QgisIface * theQgisInterface) : <br>&nbsp;&nbsp;&nbsp; QgisPlugin(sName,sDescription,sPluginVersion,sPluginType), <br>&nbsp;&nbsp;&nbsp; mQGisApp(theQGisApp), <br>&nbsp;&nbsp;&nbsp; mQGisIface(theQgisInterface),
<br>&nbsp;&nbsp;&nbsp; QgsMapTool(theQgisInterface-&gt;getMapCanvas())&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;---------------------------&nbsp; <br>{<br>&nbsp;&nbsp;&nbsp; /* do nothing */<br>}<br>[...]<br>void plugin::canvasPressEvent(QMouseEvent * e) {<br>&nbsp;&nbsp;&nbsp; QMessageBox::critical(0, QString(&quot;SEARCH&quot;), QString(&quot;Cannot create Search Window.&quot;), QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton);
<br>}<br>[...]<br><br>Thx a lot<br><br>Mathieu Ouimet<br><br><div><span class="gmail_quote">On 6/29/06, <b class="gmail_sendername">Martin Dobias</b> &lt;<a href="mailto:wonder.sk@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
wonder.sk@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On 6/28/06, Mathieu Ouimet &lt;<a href="mailto:noryoku@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">noryoku@gmail.com</a>&gt; wrote:<br>&gt; Hi,<br>&gt;<br>&gt; Is it possible to obtain a position on the map ( well-known text (wkt) or
<br>&gt; well-known binary (wkb) ) by the click of the mouse in the map canvas???&nbsp;&nbsp;Is
<br>&gt; there a fonction in the Qgis API who does that??<br><br>Hi Mathieu,<br><br>yes this is possible in current development version (which will be<br>version 0.8). You can create a plugin with your custom class derived
<br>from QgsMapCanvasTool which will handle clicks on map canvas and use<br>the position for any use you might want.<br><br>&gt;<br>&gt; Also, with a position in the wkt or wkb format, is it possible to zoom to<br>&gt; the position.&nbsp;&nbsp;Is there a fonction in the Api like
<br>&gt; &quot;zoomToPosition(position)&quot; where the position is a wkt or wkb.<br><br>You can use function QgsMapCanvas::setExtent to change extent of the<br>map canvas. For conversion from/to wkt/wkb use class QgsGeometry.
<br><br><br>Martin<br><br>&gt;<br>&gt; Thx a lot :)<br>&gt;<br>&gt; --<br>&gt; Mathieu Ouimet<br>&gt; _______________________________________________<br>&gt; Qgis-developer mailing list<br>&gt; <a href="mailto:Qgis-developer@lists.qgis.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">

Qgis-developer@lists.qgis.org</a><br>&gt; <a href="http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer
</a><br>&gt;<br>&gt;<br>&gt;<br></blockquote></div>
<br>