Reputation: 674
I would like to customize style of my application and I'm stuck on the style of TextField
pop-up menu.
TextField.style
allows to customize the look of TextField
but it doesn't contain the style of the menu. According to documentation there is a property menu
containing the Menu
so I tried something like this:
TextField {
menu.style: MenuStyle {
//...
}
}
Code above complains that property style
is non-existent so it's not exactly Menu
, it's Component
used to create the menu and I don't know if there is a way to get through it to the actual Menu
. Documentation only mentions that TextField.menu
can be set to null
to disable it completely and doesn't provide other use cases.
So is there a way to get to the menu of TextField
and change its style?
Upvotes: 2
Views: 2302
Reputation: 12874
Well, you should post all relevant code here. Anyway, you cannot define the TextField
menu and its style separately. See the example below to customize Menu
style and adding it to the TextField
inline:
TextField {
text: "text here"
anchors.centerIn: parent
menu: Menu {
style: MenuStyle {
frame: Rectangle {
color: "green"
border.color: "purple"
}
itemDelegate {
background: Rectangle {
color: "yellow"
}
label: Text {
color: styleData.selected ? "red" : "blue"
text: styleData.text
}
}
}
MenuItem { text: "Cut" }
MenuItem { text: "Copy" }
}
}
See this page for complete list of MenuStyle
properties.
Upvotes: 1