Search code examples
user-interfacefrontendqmlqqmlcomponent

How can I remove the delay of a QML ToolTip?


I rebuilt a periodic table using QML and stumbled upon the following problem. Due to size limitations I decided to reduce the amount of information that is shown to a minimum and instead implemented the option to hover over a certain element which causes a tooltip to show up, offering more information.

Periodic table

tooltip with more information

My problem is, that when you move the cursor to take a look at a different element, the tooltip will not stop showing immediately but slowly fade out instead. Rambling from side to side with your mouse will show this for example:

delayed tooltips

Is there a way to remove this fadeout and let the tooltips disappear immediately instead? Thanks in advance :)


Solution

  • This is defined in the style you are using. Either you write your own style, a custom ToolTip or overwrite manually every time. To fix it you need to overwrite the exit transition.

    Button {
        id: button
        text: qsTr("Save")
    
        ToolTip {
            parent: button
            visible: button.hovered
            delay: 500
            text: "This is a ToolTip"
            exit: Transition {}
        }
    }