Skip to content

Commit

Permalink
Improve the way how fake events are generated in CAD tools (#3302)
Browse files Browse the repository at this point in the history
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 76e55ce
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/gui/qgsmaptooladvanceddigitizing.cpp
Expand Up @@ -15,6 +15,7 @@

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


QgsMapToolAdvancedDigitizing::QgsMapToolAdvancedDigitizing( QgsMapCanvas* canvas, QgsAdvancedDigitizingDockWidget* cadDockWidget )
Expand Down Expand Up @@ -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 )
Expand Down

0 comments on commit 76e55ce

Please sign in to comment.