Qt Quick Button' hovered is true event if it's disabled
-
Hello,
I encountered an anoying problem with Qt Quick Button. I set the button to "enabled: false"
But sometimes, I hovered my mouse on it, the value of "hovered" is still true. I don't know it is a bug or not .
Further more, when I pick my mouse out of the button , some time the "hovered" is still trueCan you help me ?
Thanks
-
Hi,
Which Qt Version/OS are you using ?
-
Hello,
I'm using 5.4.0
-
That's strange, it works on Ubuntu 14.04 with Qt 5.3.2
Tried the following code
@
Item {
id: window
width: 320
height: 480Button { id: button; enabled: false text: "hover here" MouseArea { anchors.fill: parent hoverEnabled: true onEntered: { console.log("entered") } } }
}
@Can you try the above ?
-
Hello,
Actually your sample code runs well even if I do not use MouseArea.
In my case, some time it's happened. I also have binding loop with "hovered" property of button -
and how do you do it without MouseArea ? Sorry I didnt get a chance to use Qt 5.4 yet. Does it have any new added signals ?
-
You can use "hovered" as a read-only property of button. It's a built-in property and you don't need to define a MouseArea, if you define a MouseArea you can not use some Button property and its signal . These feature belongs to QtQuick Button before 5.4 . You can refer : http://doc.qt.io/qt-5/qml-qtquick-controls-button.html
There is also one signal: clicked() . It's more convenient for user than defining a MouseArea
Thanks
-
Hmm these were present in Qt 5.3.2
I tried the following new code as per it
@
Item {
id: window
width: 320
height: 480Button { id: button; enabled: false text: "hover here" } Timer { interval: 500; running: true; repeat: true onTriggered: console.log(button.hovered) }
}
@Keeping enabled to false; prints false on timeout. And when enabled set to true, true or false gets printed as expected on hover.
-
Yes, It runs ok with 5.4 . Maybe my problem relates to binding loop of "hovered" .
-
Ok. Can you post the related code then which produces the problem ?
-
Well I create a PlayBar.qml : there are 4 buttons in this files and I used a user-defined property : "isHovered" as a result of "hovered" on those 4 buttons :
@
//PlayBar.qml:
ToolBar {
id:toolBar
readonly property bool isHovered: ( btnNextFrame.hovered || btnPlayStop.hovered || btnPrevFrame.hovered
|| btnNextMovie.hovered || btnPrevMovie.hovered) )
..........................................................//Main.qml:
ApplicationWindow {PlayBar {
id: playBar
}property bool hovered: playBar.isHovered
}
@I receive a message :"Binding loop for "isHovered" in PlayBar.qml
-
Well I was not able to produce the "Binding Loop" error from above code. But it could possibly be due to the same.
-
When I roll-back to 5.3.2 there are no problem with "binding loop" and the button is not hovered when it is disable . It's very strange!!!
-
Then it could be a bug in Qt 5.4. Please report it on "Qt bug tracker":https://bugreports.qt-project.org/
-
Well, I will reproduce the problem for clearer description on bug tracker.
Anyways, thank you very much for your help!