Commit a2fd0de2 authored by Yuya Nishihara's avatar Yuya Nishihara

Add example of menu bar customization

parent fcbfafc0
import QtQuick 2.12
import QtQuick.Controls 2.12
// https://doc.qt.io/qt-5/qtquickcontrols2-customize.html#customizing-menubar
MenuBar {
id: control
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
contentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
contentHeight + topPadding + bottomPadding)
delegate: MenuBarItem {
padding: 0
spacing: 0
}
contentItem: Row {
spacing: control.spacing
Repeater {
model: control.contentModel
}
}
background: Rectangle {
//color: control.palette.window
color: "white"
Rectangle {
y: parent.height - height
width: parent.width
height: 1
//color: Fusion.mergedColors(Qt.darker(control.palette.window, 1.2),
// Qt.lighter(Fusion.outline(control.palette), 1.4), 60)
color: "#ccc"
}
}
}
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
ApplicationWindow {
id: window
......@@ -61,4 +62,23 @@ ApplicationWindow {
debugMenu.addAction(dynamicallyRegisteredAction);
}
}
Rectangle {
anchors.fill: parent
color: "white"
ColumnLayout {
anchors.fill: parent
anchors.margins: 10
spacing: 10
Label { text: "Fully-customized menu bar:" }
CustomMenuBar {
Menu { title: qsTr("&Foo") }
Menu { title: qsTr("&Bar") }
}
Item { Layout.fillHeight: true }
}
}
}
<RCC>
<qresource prefix="/">
<file>CustomMenuBar.qml</file>
<file>main.qml</file>
<file>qtquickcontrols2.conf</file>
</qresource>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment