6 Star 19 Fork 24

韦东山 / Qtmxapp-desktop

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
MyImgButton.qml 1.62 KB
一键复制 编辑 原始数据 按行查看 历史
世玉轩 提交于 2020-06-19 09:31 . init push myir hmi v2.0 gui
import QtQuick 2.0
/* 桌面图片按钮的实现,上面图片,下面文本*/
Rectangle {
id: root
visible: true
width: 130
height: width
radius: width/20
color: clr_backgroud
// border.color: "green"
// border.width: 1
property alias img_source: image.source
property alias img_size: image.width
property alias button_text: button.text
property color clr_backgroud: "transparent" //背景透明色
property color clr_entered: "lightgray"
property color clr_exited: clr_backgroud
property color clr_pressed: "lightslategray" //点击效果
property int margin: 10
signal clicked
Image {
id: image
source: "qrc:/res/icon/icon_camera.png"
width: 80
height: width
anchors.horizontalCenter: root.horizontalCenter
anchors.top: root.top
anchors.margins: root.margin
}
Text {
id: button
text: qsTr("相机")
font.bold: true
font.pixelSize: 25
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
anchors.horizontalCenter: root.horizontalCenter
anchors.top: image.bottom
anchors.margins: root.margin
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton; //只接受左键
hoverEnabled: true
onClicked: parent.clicked()
onEntered: root.color = clr_entered
onExited: root.color = clr_exited
onReleased: root.color = clr_entered
onPressed: root.color = clr_pressed;
}
}
C++
1
https://gitee.com/weidongshan/Qtmxapp-desktop.git
git@gitee.com:weidongshan/Qtmxapp-desktop.git
weidongshan
Qtmxapp-desktop
Qtmxapp-desktop
master

搜索帮助