QML学习
main.qml
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
Window {
width: 640
height: 480
visible: true
title: qsTr("MenuBar&ToolBar")
// 菜单栏
MenuBar {
id: menuBar
contentWidth: parent.width
// 绘制菜单栏背景
background: Rectangle {
color: "lightGray"
Rectangle {
width: parent.width
height: 1
anchors.bottom: parent.bottom
color: "black"
}
}
// 菜单选项代理
delegate: MenuBarItem {
// 绘制菜单选项背景