Congratulations to our 2022 Qt Champions!

Few tooltip question

  • Hi everyone, I'm a new hand in qml, and my english is very poor.
    in my project, i have to implement a tooltip in some buttons.
    I saw some code here, and I found out this.
    In this code, the tooltip will show up when the mouse move into the mouse area.
    How can I make the tooltip show up when mouse move into the mouse area and stay in mouse area for 3 or 5 seconds?
    Is there is a signal or function can detect how long the mouse stay in a mouse area?

    Thank for every response

  • Hi lesner,
    You can use Timer and listen hoverd event in MouseArea like this:
    @ Timer {
    id: timer

        repeat: false;
        running: false
        interval: 3000 // 3 sec.
        onTriggered: {
            console.log("show tip");
            button.hovered = true;
        MouseArea {
            id: ma
            anchors.fill: parent
            hoverEnabled: true
            onHoveredChanged: {
                if (ma.containsMouse) {
                } else {
                    button.hovered = false;

  • I don't think there is a signal for that. But I suppose you could solve this by starting a "Timer": when the mouse enters the area and interput it (using "stop()": if the mouse leaves before the Timer is finished. When the timer fires you just open the tooltip.

  • thanks a lot!!
    that's very useful !!

Log in to reply