When hovering your mouse over a layer, a tooltip appears showing the layer's source. E.g. for a virtual layer:

Layer's tooltip

Is it possible to change this tooltip either through an existing option or PyQGIS?

I noticed the QgsDataItem class has a setToolTip() method, can something similar be used?


I don't know if it is possible removing the layer's source (I will try to investigate), but you may add a title and an abstract in this way:



You will obtain:

enter image description here

  • Ahh many thanks, I see this can also be edited from Layer Properties > Metadata. It's certainly useful as a workaround :) – Joseph Mar 8 '17 at 15:15
  • @Joseph I initially wanted to post this answer as a comment because I'm sure you want to directly edit the tooltip... I'll edit my answer if I find something more interesting! – mgri Mar 8 '17 at 15:21
  • 1
    I'm glad you posted it as an answer as this atleast is something I can work with =) – Joseph Mar 8 '17 at 15:24

This has been bugging me, I'd like to tweak that myself - I'd love to be able to hover the mouse over and see the CRS as well as the source.

I managed to hunt down the code that does this. GitHub has a really good full text search, by searching for abstract setToolTip I was able to find the code. I'm not a C++ developer, but I can get the gist of C++ code and it seems to tie in with the answer from @mgri

It's in a class called qgsMapLayerModel, in a method called data in particular this block

There seems to be a SIP wrapper for this, so it's probably doable with pyqgis by subclassing this and overriding this method... it's a bit late so I won't attempt to tackle this just now, but hopefully point us both in the right direction :)

  • Interesting, great detective work! I'll also take a look at it when I have some spare time but could be doable :) – Joseph Mar 20 '17 at 10:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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