qt - How to make image to fill qml controls button -
i want icon fill button
. here code:
import qtquick 2.3 import qtquick.controls 1.2 import qtquick.layouts 1.1 import qtquick.window 2.2 window{ id: root title: "settings" flags: qt.dialog minimumheight: 700 minimumwidth: 700 maximumheight: 700 maximumwidth: 700 columnlayout{ id: columnlayout anchors.fill: parent rowlayout{ button{ iconsource: "images/1x1.png" checkable: true checked: true layout.minimumwidth: 100 layout.minimumheight: 100 } button{ iconsource: "images/1x2.png" checkable: true checked: false layout.minimumwidth: 100 layout.minimumheight: 100 } button{ iconsource: "images/2x1.png" checkable: true checked: false layout.minimumwidth: 100 layout.minimumheight: 100 } button{ iconsource: "images/2x2.png" checkable: true checked: false layout.minimumwidth: 100 layout.minimumheight: 100 } } rectangle{ visible: true implicitheight: 600 implicitwidth: 700 color: "red" } } }
button size 100*100 pixels image size lower. how make image big button
if don't mind using private api, there's padding property:
import qtquick 2.4 import qtquick.controls 1.2 import qtquick.controls.styles 1.2 item { width: 200 height: 200 button { iconsource: "http://www.sfweekly.com/imager/the-exhikittenist-cattown-cat-pics-and-m/b/square/3069319/58c8/wikicat.jpg" anchors.centerin: parent style: buttonstyle { padding { left: 0 right: 0 top: 0 bottom: 0 } } rectangle { anchors.fill: parent color: "black" opacity: parent.pressed ? 0.5 : 0 } } }
looking @ buttonstyle.qml
:
/*! padding between background , label components. */ padding { top: 4 left: 4 right: control.menu !== null ? math.round(textsingleton.implicitheight * 0.5) : 4 bottom: 4 }
Comments
Post a Comment