Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Few tooltip question
Qt 6.11 is out! See what's new in the release blog

Few tooltip question

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 3 Posters 2.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lesner
    wrote on last edited by
    #1

    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.
    http://qt-project.org/forums/viewthread/1686
    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

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      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: {
                  console.log(ma.containsMouse);
                  if (ma.containsMouse) {
                      timer.start();
                  } else {
                      button.hovered = false;
                      timer.stop();
                  }
              }
          }@
      
      1 Reply Last reply
      0
      • L Offline
        L Offline
        lycis
        wrote on last edited by
        #3

        I don't think there is a signal for that. But I suppose you could solve this by starting a "Timer":http://doc.qt.nokia.com/4.7-snapshot/qml-timer.html when the mouse enters the area and interput it (using "stop()":http://doc.qt.nokia.com/4.7-snapshot/qml-timer.html#stop-method) if the mouse leaves before the Timer is finished. When the timer fires you just open the tooltip.

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lesner
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved