I have a layer in my system that displays nautical sectorlights. If sectorlights are close together the symbology overlaps, wрich I don't want.

I would like to see the star at all times, but see the dotted lines, colors and arc-indicator when the layer is active and I hold my mouse on the star.

Are mouseover actions possible in QGIS? Can a mouseover action be invoked as a parameter in an Expression Builder?

For example:

Enable layer:

[mouseover]=true, 1, 0)

At the moment I am using a layer without geometry as a reference layer. I keep the attribute table open while working and if i check the box on "sectorlichten-uitgebreid" the symbology will show on screen. I had hoped to evolve to a mouse-over action, my thoughts: There is mouse-over functionality being used on maptips and, in a way, the snapping-function is doing what I am looking for: when you come within a set px of a point, a purple box (symbology) will appear, indicating you are snapping to a geometry. I had hoped this signal was available to invoke functionality in the expression-builder.

enter image description here enter image description here

  • 3
    If you can't find a way to detect a mouseover, the is_selected function would make a crude workaround.
    – csk
    Nov 21, 2019 at 15:53
  • I don't see any existing function to detect a mouseover or cursor location. You might need to write a custom function. That's probably pretty simple if you know python. If not, you'll run into the GIS stackexchange catch-22, where you can't ask about coding if you don't already have some code.
    – csk
    Nov 21, 2019 at 16:06

3 Answers 3


This is a workaround, not a direct answer. To achieve what you actually wanted, with symbols only appearing when you mouse over the feature, you could probably write a custom function.

The is_selected function is the closest to a [mouseover] function in the existing Expression Builder Functions. Here's how to use it to control symbology:

Here's what my layer looks like before:

enter image description here

  1. In the Layer styling panel, select the symbol layer that has the dotted lines, colors and arc-indicator.
  2. Click on the data-defined override button next to the words "enable layer" at the bottom of the panel (you may need to scroll down).
  3. Enter the expression is_selected().

    enter image description here

    Here's what it looks like now, with one point selected:

    enter image description here

    To activate the symbol layer, you'll have to select the feature (as opposed to just mousing over it like you wanted). When the feature is selected, it becomes whatever color is set for selected features. By default, that color is opaque yellow. Now instead of overlapping symbols, you have one symbol that completely obscures its neighbors. Obviously that's not ideal.

  4. Go into project properties. Change the selection color to transparent. Now the selected feature shows the symbology you want.

    enter image description here

Note: changes to the feature selection color will apply to all the layers in the project. You might want to choose a semi-transparent selection color instead of fully transparent, so you can still tell when features in other are selected. Here's what my layer looks like with 30% opacity:

enter image description here

  • thnx for this, I will use this untill mouse-over functionality has been added to the expressionbuilder/I have money to pay a pythondev / i can write it myself. Nov 21, 2019 at 19:17
  • Happy to help. It might be worth searching to see if someone else has written an custom function for this already. I doubt you're the first to want this feature.
    – csk
    Nov 21, 2019 at 19:29

This post builds upon @csk's answer where you can create a custom function to use in conjunction with Map tips. This will let you hover over a feature and see only that feature's symbology.

After you have used the is_selected() expression for each of your symbol layers (excluding the star), right-click your layer and go to Properties > Display:

Maptip interface

Click the epsilon button highlighted in the blue circle. Now we can define a new function by either editing an existing file or creating a new one. Then use the following code, change to match the name of your layer:

from qgis.core import *
from qgis.gui import *

canvas = qgis.utils.iface.mapCanvas()
layer = QgsProject.instance().mapLayersByName("Point example")[0]

def hide():

@qgsfunction(args='auto', group='Custom')
def show(feature, parent):
    single_symbol_renderer = layer.renderer()
    symbol = single_symbol_renderer.symbol()
    for x in symbol.symbolLayers()[:-1]:
        if feature:

Creating function

What the code does is when Map tips is enabled from the toolbar, it checks to see where the cursor is. If it is hovering over a feature, it will select it automatically. A second function is connected to a signal which is emited when the xy coordinate changes on canvas (i.e. when the cursor moves). This function then deselects all features, thus hiding the symbology again.

Now click the Save and Load Functions button. Then set the function using the expression show() and click the Insert button or type it in directly using [% show() %].

Set expression

Click Apply and OK. Now when you hover over your feature, the relevant symbology should be applied.


  • I have tried this, and the mechanism works! The problem I know have is that i shows the degree-indicator properly cause it's a SVG image beeing loaded and corrected for meridian convergention. But the non-svg (dotted lines, black circle, color-indicators and white background of degree-indicator) are no longer displayed Nov 22, 2019 at 14:05
  • @CaptainAhab - You may have to play around with the ordering of the symbol layers.
    – Joseph
    Nov 22, 2019 at 14:35
  • Out of curiosity: i don’t think i’m the only one who’d like to have this added as standard functionality in the expression-builder. Where do I need to make my case about it? I wouldnt mind paying for this Nov 23, 2019 at 18:36

Maybe you can do it without programming much by using the Map Tips or HTML Map Tips tool:

enter image description here

HTML Map Tips can be styled more sensibly, but I am not sure about the rotation you need to apply, maybe an svg transform statement?

There is an old but nice tutorial here.

  • Is it possible to recreate the elaborate symbology in that screenshot? I thought maptips were always inside a rectangle.
    – csk
    Nov 21, 2019 at 15:51
  • Thnx for your quick respons. how will this enable (parts of) the symbology? It only lets me see some information that is pulled form the database? or am I missing something? Nov 21, 2019 at 15:53
  • @csk you are right. maybe using a transparent HTML background would partly help? Nov 21, 2019 at 15:53
  • I think the placement of the maptip would be an issue, as well as re-creating the entire symbology.
    – csk
    Nov 21, 2019 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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