[Qgis-developer] Canvas Press Event overriding
Mathieu Ouimet
noryoku at gmail.com
Thu Jul 6 14:06:44 EDT 2006
Hi,
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??
/***************** plugin.h
[...]
#include <qgsmaptool.h>
[...]
class plugin : public QObject, public QgisPlugin, public QgsMapTool {
Q_OBJECT;
public:
virtual ~plugin();
plugin(QgisApp * theApplication, QgisIface * theInterface);
virtual void canvasPressEvent(QMouseEvent * e);
public slots:
[...]
private:
[...]
/***************** plugin.cpp
[...]
#include "plugin.h"
QGISEXTERN QgisPlugin * classFactory(QgisApp * theQGisAppPointer, QgisIface
* theQgisInterfacePointer) {
return new plugin(theQGisAppPointer, theQgisInterfacePointer);
}
[...]
plugin::plugin(QgisApp * theQGisApp, QgisIface * theQgisInterface) :
QgisPlugin(sName,sDescription,sPluginVersion,sPluginType),
mQGisApp(theQGisApp),
mQGisIface(theQgisInterface),
QgsMapTool(theQgisInterface->getMapCanvas())
<---------------------------
{
/* do nothing */
}
[...]
void plugin::canvasPressEvent(QMouseEvent * e) {
QMessageBox::critical(0, QString("SEARCH"), QString("Cannot create
Search Window."), QMessageBox::Ok, QMessageBox::NoButton,
QMessageBox::NoButton);
}
[...]
Thx a lot
Mathieu Ouimet
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20060706/77b252e2/attachment.html
More information about the Qgis-developer
mailing list