MyToolBar.qml
import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick.Controls.impl 2.14
import QtQuick.Templates 2.14 as Template
Template.ToolBar {
id: control
property color backgroundColor: "#36c588"
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
contentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
contentHeight + topPadding + bottomPadding)
background: Rectangle {
implicitHeight: 30
color: control.backgroundColor
}
}
调用:
MyToolBar {
id:toolBarPatient
x:200
y:35
visible: true
width: 600
RowLayout{
layoutDirection: Qt.LeftToRight
MyToolButton{
text: ""; icon.source: "qrc:/image/patient/patient.png"; ToolTip.visible: hovered;ToolTip.text: qsTr("添加患者")
WndPatientAdd
{
id: wndPatientAdd
}
onClicked:
{
wndPatientAdd.show();
}
}
MyToolButton{ text: ""; icon.source: "qrc:/image/patient/patient.png"; ToolTip.visible: hovered;ToolTip.text: qsTr("添加信息") }
MyToolButton{ text: ""; icon.source: "qrc:/image/patient/patient.png"; ToolTip.visible: hovered;ToolTip.text: qsTr("删除信息") }
MyToolButton{ text: ""; icon.source: "qrc:/image/patient/patient.png";
}
}