Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm using

QgisInterface->mapCanvas()->scene()->addItem(QGraphicsTextItem)

to add a QGraphicsTextItem to the map canvas. The problem is that when I use the pan tool to move the display the added QGraphicsTextItem is not moving !
How can I make it update its position whenever the pan tool is used on the map ?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

You need to align the position of the item to the new canvas extent. Either connect to the QgsMapCanvas::extentsChanged() signal and update the QGraphicsTextItem from there. Or derive a class from QgsMapCanvasItem and implement a paint method that takes the current map canvas extent into account (QgsMapCanvasItem has some methods in that direction).

QgsTextAnnotationItem might also fit your needs or at least be an example how to implement your class.

share|improve this answer
    
Many Thanks jef, that worked ;) –  QgisTn Jun 19 '12 at 7:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.