Skip to content
Permalink
Browse files

Improve the way how fake events are generated in CAD tools (#3302)

In my custom tool in python, the generated fake event received in cadCanvasMoveEvent()
was actually QMouseEvent instance instead of QgsMapMouseEvent, suggesting something
dodgy going on behind the scenes. The actual reason was that first argument was
QMouseEvent::Move instead of QEvent::MouseMove (not sure why the cast did not work though)

The new approach seems safer as the event goes through the ordinary event processing
  • Loading branch information
wonder-sk authored and m-kuhn committed Jul 13, 2016
1 parent 5a20313 commit 76e55ce72e2fd3a695fff2bdfa972d6ce40eee4f
Showing with 4 additions and 3 deletions.
  1. +4 −3 src/gui/qgsmaptooladvanceddigitizing.cpp
@@ -15,6 +15,7 @@

#include "qgsmapmouseevent.h"
#include "qgsmaptooladvanceddigitizing.h"
#include "qgsmapcanvas.h"


QgsMapToolAdvancedDigitizing::QgsMapToolAdvancedDigitizing( QgsMapCanvas* canvas, QgsAdvancedDigitizingDockWidget* cadDockWidget )
@@ -69,9 +70,9 @@ void QgsMapToolAdvancedDigitizing::deactivate()

void QgsMapToolAdvancedDigitizing::cadPointChanged( const QgsPoint& point )
{
QgsMapMouseEvent fakeEvent( mCanvas, QMouseEvent::Move, QPoint( 0, 0 ) );
fakeEvent.setMapPoint( point );
canvasMoveEvent( &fakeEvent );
Q_UNUSED( point );
QMouseEvent* ev = new QMouseEvent( QEvent::MouseMove, mCanvas->mouseLastXY(), Qt::NoButton, Qt::NoButton, Qt::NoModifier );
qApp->postEvent( mCanvas->viewport(), ev ); // event queue will delete the event when processed
}

void QgsMapToolAdvancedDigitizing::snap( QgsMapMouseEvent* e )

0 comments on commit 76e55ce

Please sign in to comment.
You can’t perform that action at this time.