[solved]Button: checkable and checked not working
-
wrote on 11 Jan 2014, 12:07 last edited by
Hi experts!
I recently started learning qml and I am now playing with the controls a bit.
My goal is to have a checkable button. However, the property checkable doesn't seem to have any influence on the button: The button does not remain pressed. Also, if setting checked to true, the button is not in the pressed state.
code snippet:
@
import QtQuick 2.0
import QtQuick.Controls 1.0Rectangle {
width: 360
height: 360
Text {
text: qsTr("Hello World")
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
onClicked: {
Qt.quit();
}
}
Button{
text: "asdfs"
checkable: true
checked: true
}
}
@some infos:
- using qt5.1.1
- tried it in window and ubuntu
- tried "Button" as well as "ToolButton"
Did I miss something? Do you have some ideas why it is not working as intended? Thank you for any help! :)
-
Hi,
I guess the button state gets change to pressed but is not seen on the button widget as it should be by default like the QPushbutton.
Applying the stylesheet make it work though,
@
Button{
text: "asdfs"
checkable: true
checked: true
style: ButtonStyle {
background: Rectangle {
border.width: control.activeFocus ? 2 : 1
border.color: "#888"
radius: 4
color: control.checked ? "#ccc" : "#eee"
}
}
}
@ -
wrote on 11 Jan 2014, 22:53 last edited by
Thank you very much for the quick reply!
The stylesheet does the trick :)
Fortunately, in qt5.2, it works out of the box... -
1/3