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. Recommended approach for displaying tooltips

Recommended approach for displaying tooltips

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 5 Posters 7.7k 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.
  • C Offline
    C Offline
    cbrake
    wrote on last edited by
    #1

    Hello,

    I have a QML application with a number of buttons and would like to display a "tooltip" when the mouse is over top the button. What is the recommended way to do this with QML?

    Thanks,
    Cliff

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alexander
      wrote on last edited by
      #2

      Are you writing application for desktop platforms? I suppose - one way - writing your own code for this.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        korzhp
        wrote on last edited by
        #3

        look at http://qt.gitorious.org/qt-components

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mbrasser
          wrote on last edited by
          #4

          Hi,

          You should be able to emulate tooltips using the basic QML items. Here's an example -- its not very pretty, and very limited (no delay, only one button, etc), but hopefully it will give you some ideas.

          @
          import QtQuick 1.0

          Rectangle {
          width: 200
          height: 200

          property bool needTooltip: button.hovered
          property real tooltipX: button.x
          property real tooltipY: button.y
          
          Rectangle {
              id: button
              property bool hovered: ma.containsMouse
              width: 100; height: 100
              anchors.centerIn: parent
              color: "steelblue"
              Text {
                  anchors.centerIn: parent
                  text: "My Button"
              }
              MouseArea {
                  id: ma
                  anchors.fill: parent
                  hoverEnabled: true
              }
          }
          
          Rectangle {
              id: tooltip
              width: 75; height: 20
              visible: false
              color: "red"
              Text {
                  anchors.centerIn: parent
                  text: "My Tooltip"
              }
          
              states: State {
                  name: "inuse"
                  when: needTooltip
                  PropertyChanges {
                      target: tooltip
                      visible: true
                      x: tooltipX + 12
                      y: tooltipY - 30
                  }
              }
          }
          

          }
          @

          Regards,
          Michael

          1 Reply Last reply
          0
          • A Offline
            A Offline
            anselmolsm
            wrote on last edited by
            #5

            [quote author="korzhp" date="1289378399"]look at http://qt.gitorious.org/qt-components[/quote]

            As korzhp said, take a look at Qt-Components. There you'll find a QML implementation of the Mx toolkit; in src/Mx/ you find the implementation of a tooltip. Run examples/mx/test.qml to see it in action in the Mx widgets gallery :-)

            Anselmo L. S. Melo (anselmolsm)

            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