Files
eUi/components/ToolBarButton.qml
T

54 lines
1.3 KiB
QML

import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Controls.Basic 2.15
import "qrc:/"
Button {
id: toolBarButton
property string iconSource: ""
property color hoverColor: Colors.sColor_GoldWithBlack
property int buttonWidth: 40 // 默认宽度
property int buttonHeight: 40 // 默认高度
width: buttonWidth
height: buttonHeight
implicitWidth: buttonWidth
implicitHeight: buttonHeight
background: Rectangle {
width: parent.width
height: parent.height
color: "transparent"
border.color: "red"
border.width: 0
radius: 0
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
onEntered: {
parent.color = toolBarButton.hoverColor
}
onExited: {
parent.color = "transparent"
}
onClicked: {
// 确保第一次点击有效果
console.log("Button clicked");
}
}
}
contentItem: Image {
id: image
source: toolBarButton.iconSource
width: toolBarButton.buttonWidth
height: toolBarButton.buttonHeight
fillMode: Image.PreserveAspectFit
anchors.centerIn: parent
}
}