<div>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?? I put a message box when the mouse is clicked on the
canvas but I never get the message. Is it the constructor and i don't
initialize the QgsMapTool correctly??
<br><br>/***************** plugin.h<br><br>[...]<br>#include <qgsmaptool.h><br>[...]<br>class plugin : public QObject, public QgisPlugin, public QgsMapTool {<br> Q_OBJECT;<br> public:<br> virtual ~plugin();
<br> plugin(QgisApp * theApplication, QgisIface * theInterface);<br> virtual void canvasPressEvent(QMouseEvent * e);<br> public slots:<br> [...]<br> private:<br> [...]<br><br>/*****************
plugin.cpp<br><br>[...]<br>#include "plugin.h"<br>QGISEXTERN QgisPlugin * classFactory(QgisApp * theQGisAppPointer, QgisIface * theQgisInterfacePointer) {<br> return new plugin(theQGisAppPointer, theQgisInterfacePointer);
<br>}<br>[...]<br>plugin::plugin(QgisApp * theQGisApp, QgisIface * theQgisInterface) : <br> QgisPlugin(sName,sDescription,sPluginVersion,sPluginType), <br> mQGisApp(theQGisApp), <br> mQGisIface(theQgisInterface),
<br> QgsMapTool(theQgisInterface->getMapCanvas()) <--------------------------- <br>{<br> /* do nothing */<br>}<br>[...]<br>void plugin::canvasPressEvent(QMouseEvent * e) {<br>
QMessageBox::critical(0, QString("SEARCH"), QString("Cannot create
Search Window."), QMessageBox::Ok, QMessageBox::NoButton,
QMessageBox::NoButton);
<br>}<br>[...]</div><span class="q"><br><br>Thx a lot<br><br>Mathieu Ouimet</span>