Reputation: 1
i am new to the forum and i started designing several things in QtQuick. I am still exploring and learning the basic stuff and i stumbled upon the following problem. When i try to create a menu (menubar) from a ListModel using Listview, i simply dont get any menu at all. Maybe i have still an misunderstanding about the principles and you can help me. Here is my basic code:
import QtQuick 2.12
import QtQuick.Window 2.14
import QtQuick.Layouts 1.12
import QtQuick.Dialogs 1.3
import QtQuick.Controls 2.14
MenuBar{
id: menuBarId
ListModel{
id: listModelMenuId
ListElement {menuname: "Test1"}
ListElement {menuname: "Test2"}
}
ListView{
id: listViewMenuId
model: listModelMenuId
delegate: Menu {
id: menu
title: model.menuname
Action { text: qsTr("Tool Bar"); checkable: true }
Action { text: qsTr("Side Bar"); checkable: true; checked: true }
Action { text: qsTr("Status Bar"); checkable: true; checked: true;}
MenuSeparator {
contentItem: Rectangle {
implicitWidth: 200
implicitHeight: 1
color: "#21be2b"
}
}
Menu {
title: qsTr("Advanced")
}
topPadding: 2
bottomPadding: 2
// delegate: mydelegateid
background: Rectangle {
implicitWidth: 200
implicitHeight: 40
color: "#ffffff"
border.color: "#21be2b"
radius: 2
}
}} }
I got my sample from the qt site and tampered with it by adding the ListModel. Also interesting is that if i want to refactor the original coding by using a component where i pack up the MenuItem and call the compoenent it also not works. Can it be that menus in general work different thand other Items? If i left something important out just tell me, i'll add more information.
Best regards!
Upvotes: 0
Views: 225
Reputation: 1
i resolved the issue. Example to delegate your style in a MenuBar
This resolved the problem in general. However, i still wonder why i can not encapsulate the MenuItem into a component and use the components id to delegate the style for the items.... Regards, Seryoga
Upvotes: 0