These menus by default appear on the left side. I want to place some text on the left side before the menu starts appearing.
How to push the menus to right in order to create space for the text in the menubar?
That text “AmplifyRemote” is appearing before the menu starts. How to achieve that here?
JavaScript
x
58
58
1
ApplicationWindow
2
{
3
id: window; visible: true; width: Screen.width; height: Screen.height; flags: Qt.FramelessWindowHint
4
5
menuBar:
6
MenuBar
7
{
8
id: menuBar
9
10
Menu { title: qsTr("File") }
11
Menu { title: qsTr("Edit") }
12
Menu { title: qsTr("View") }
13
Menu { title: qsTr("Help") }
14
15
delegate: MenuBarItem {
16
id: menuBarItem
17
18
font
19
{
20
pointSize: decoration.font_size_8
21
family: decoration.font_family
22
}
23
contentItem: Text {
24
text: menuBarItem.text
25
font: menuBarItem.font
26
opacity: enabled ? 1.0 : 0.3
27
color: menuBarItem.highlighted ? "white":"#3F3F3F"
28
horizontalAlignment: Text.AlignLeft
29
verticalAlignment: Text.AlignVCenter
30
elide: Text.ElideRight
31
}
32
33
background: Rectangle {
34
implicitWidth: 40
35
implicitHeight: 40
36
opacity: enabled ? 1 : 0.3
37
color: menuBarItem.highlighted ? "#292a38" : "transparent"
38
}
39
}
40
41
background: Rectangle {
42
implicitWidth: 40
43
implicitHeight: 11
44
color: "#d2d2d2"
45
46
// This is the text I want before menus start
47
Text{ text:"jjjjjjjjj"; anchors.left: parent.left}
48
49
Rectangle {
50
color: "#21be2b"
51
width: parent.width
52
height: 1
53
anchors.bottom: parent.bottom
54
}
55
}
56
}
57
}
58
Advertisement
Answer
It’s possible there are prettier solutions, but it can work by adding a special Menu item to the front of your list that is disabled.
JavaScript
1
16
16
1
MenuBar {
2
id: menuBar
3
4
Menu { title: "jjjjjjjj" }
5
Menu { title: qsTr("File") }
6
Menu { title: qsTr("Edit") }
7
Menu { title: qsTr("View") }
8
Menu { title: qsTr("Help") }
9
10
delegate: MenuBarItem {
11
id: menuBarItem
12
13
enabled: text !== "jjjjjjjj"
14
}
15
}
16