Anybody know how I can change the color of the control "RoundButton", present in the present in Qt Controls since 2.1.
I tried changing the background, but if I put "Rectangle" at the item the RoundButton became rectangular and I don't know what to put instead.
RoundButton {
id: roundButton
x: 243
y: 244
width: 20
height: 20
text: "ah"
wheelEnabled: false
background: Rectangle {
color: "yellow"
height: 50
width: 50
}
}
With Qt 5.10 you can use the palette property to avoid having to override the background:
import QtQuick 2.9
import QtQuick.Controls 2.3
ApplicationWindow {
visible: true
RoundButton {
id: button
text: "ah"
palette.button: "salmon"
}
}
Not all styles currently respect the palette property though: the Default and Fusion styles do, and the Imagine style does, where it can (mostly text colours, as it's an image-based style).
If you're curious which palette role to use for a particular style, it's probably easiest to look to the source code:
http://code.qt.io/cgit/qt/qtquickcontrols2.git/tree/src/imports/controls/Button.qml#n77
Although the list of roles is documented:
https://doc.qt.io/qt-5.10/qml-palette.html#qtquickcontrols2-palette