Button with iconSource - how to set size?
-
I have a button with iconSource. How can I set button size exactly as icon size? I don't want to set width and height as constants.
@
RowLayout {
....
Button {
iconSource: <some image from resource>
Layout.preferredWidth: ?
Layout.preferredHeight: ?
}
}
@ -
Hi,
The Button size should get adjusted according to the image size.
-
Hi,
No, it does not. Maybe RowLayout adjust button size according to its internal logic.My button does not have Layout.preferred*, Layout.fill* properties, nevertheless its size is 3031, while image size is 2323
-
Hmm. Missed the word exactly in your question. Seems it pads some space throughout.
-
Yes the default Button style adds some space. Are you open to using ButtonStyle ? It works.
@
Button {
id: b
style: ButtonStyle {
background: Image {
source: "file:///root/star.png"
}
}
onClicked: { console.log(b.width,b.height) }
}
@ -
Nice workaround! It really works. Not sure I can use it, but thank you, p3c0 :)