首页| 论坛| 消息

标题:Qml MenuItem 改变文字颜色
作者:pppop3
日期:2014-09-19 15:23
内容:

Menu {
title: "文件(&F)"
MenuItem {
id:openMenu
text:"打开"
shortcut: "Ctrl+s"
}
MenuItem {
text: "关闭"
shortcut: "Ctrl+p"
}
MenuItem {
text: "你好"
shortcut: "Ctrl+,"
}
}
请问怎么修改Menu 和MenuItem 的字体颜色,我尝试用style但是发现itemDelegate是只读的 或者说 我要自己定义一个itemDelegate ?最好有资料或者例子 谢谢给位


#1 [qyvlik 04-21 00:01]
Menu{
property int size: FlatGlobal.sizeDefault
property ActiveColor type : FlatGlobal.typeDefault;
// because the frame color is same as typeInverse.color;
onTypeChanged:{
if(type.objectName == FlatGlobal.typeInverse.objectName){
type = Qt.binding(function(){
return FlatGlobal.typeDefault;
});
}
}
style:MenuStyle {
frame:Rectangle{
color:FlatGlobal.typeInverse.inactiveColor;
//radius: FlatGlobal.radius;
}
itemDelegate.background : Rectangle {
color:FlatGlobal.typeInverse.inactiveColor;
//radius: FlatGlobal.radius;
}
itemDelegate.label: Label {
font.family: FlatGlobal.font.family;
font.pointSize: size;
text:styleData.text
color:styleData.selected ? type.activeColor :type.inactiveColor
&n ..

回复 发表
主题 版块