void QgsMapToolAnnotation::keyPressEvent( QKeyEvent* e ) { if ( e->key() == Qt::Key_T && e->modifiers() == Qt::ControlModifier ) { toggleTextItemVisibilities(); } QgsAnnotationItem* sItem = selectedItem(); if ( sItem ) { if ( e->key() == Qt::Key_Delete ) { if ( mCanvas && mCanvas->scene() ) { QCursor neutralCursor( sItem->cursorShapeForAction( QgsAnnotationItem::NoAction ) ); mCanvas->scene()->removeItem( sItem ); delete sItem; mCanvas->setCursor( neutralCursor ); } } } }
void QgsMapToolAnnotation::keyPressEvent( QKeyEvent *e ) { if ( e->key() == Qt::Key_T && e->modifiers() == Qt::ControlModifier ) { toggleTextItemVisibilities(); } QgsMapCanvasAnnotationItem *item = selectedItem(); if ( item ) { if ( e->key() == Qt::Key_Backspace || e->key() == Qt::Key_Delete ) { QCursor neutralCursor( item->cursorShapeForAction( QgsMapCanvasAnnotationItem::NoAction ) ); QgsProject::instance()->annotationManager()->removeAnnotation( item->annotation() ); if ( mCanvas ) { mCanvas->setCursor( neutralCursor ); e->ignore(); } } } }