I am trying to create a button like control in QML which displays an image and also some text under it. My current attempt stands as follows:
Item {
id: button
width: 30
height: 100
property alias text: buttontext
signal clicked
Image {
id: visualImage
anchors.fill: parent
source: "qrc:/images/test.png"
}
Text {
id: buttontext
font.bold: true
text: "Test"
}
}
This has a lot of problems unfortunately. So, at the moment, I am specifying the width and height of the item but this should be calculated based on the width and height of the image and the text. Also, the text is shown at the top and inside the image where I would like to position the text under the image, centered with image horizontally with some margins.
Button(<-clickable) class of qml and specify it's icon, text and style options. You can also createMouseAreawithImageandTextinside (you can specifyzoption to makeTextto be drawn underImage). You can also create your own component, though it may be overkill in most situations. - user2487382Column, it's really easy to use. Setwitdh:parent.widthto both image and text and also sethorizontalAlignment: Text.AlignHCenterto the text: that's it. - BaCaRoZzo