2

I'm writing a test application to try out what QML has to offer. I have created a simple button and tried to create a tooltip on mouse hover event. I found several solutions already how to make that happen (example) and it is not a problem.

In the documentation, however, I have encountered a button property called tooltip. Now I assumed if a built-in component has such a property then creation of tooltip is automated. Apparently that is not the case, since defining tooltip property did not change anything.

The question is what is this property actually used for?

Button {
    id: myButton
    x: 10
    y: 10
    text: "Click me"
    tooltip: "Some tooltip"
}
Community
  • 1
  • 1

1 Answers1

4

Showing of tooltip requires receiving of mouse hover events and this is possible only if your button is not overlapped with some another MouseArea with hoverEnabled property equal to true. Following example shows tooltip fine on OS X and Qt 5.2.1:

import QtQuick 2.0
import QtQuick.Controls 1.1

Rectangle {
    width: 360
    height: 360
    Text {
        anchors.centerIn: parent
        text: "Hello World"
    }
    Button {
        id: myButton
        x: 10
        y: 10
        text: "Click me"
        tooltip: "Some tooltip"
    }
}
Max Go
  • 2,092
  • 1
  • 16
  • 26