【发布时间】:2016-06-23 08:25:29
【问题描述】:
我有一个语言选择列表的代表。列表中的每个项目都包含一个图标和文本。 我想将组件定义移动到不同的文件中,并将当前由 IMGDIR 定义的字符串作为属性提供。
只需将下面的整个文本移动到单独的 LandDelegate.qml 文件中,并将其包含为:
LangDelegate { id: langDlg }
没用。
下面是组件的声明。
Component {
id: langDlg
Item {
id: wrapper
width: langView.width
height: langImg.height+10*2
Rectangle {
id: background
x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2
color: "lightgrey"
border.color: "orange"
radius: 5
}
states: State {
name: "Current"
when: wrapper.ListView.isCurrentItem
PropertyChanges { target: wrapper; x: 20 }
}
transitions: Transition {
NumberAnimation { properties: "x"; duration: 200 }
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onEntered: { wrapper.ListView.view.currentIndex = index; }
onClicked: { wrapper.ListView.view.currentIndex = index; langSelect.visible = false; docView.visible = true }
}
Row {
id: topLayout
x: 10; y: 10; height: langImg.height + 10*2; width: parent.width
spacing: 10
Image {
id: langImg
//width: 50; height: 50
source: IMGDIR+licon
}
Column {
width: background.width - langImg.width - 20; height: langImg.height
spacing: 5
Text {
text: lname
font.bold: true; font.pointSize: 16
}
}
}
}
}
【问题讨论】:
-
@Mitch 不,不起作用。无论如何感谢您的贡献:-)
标签: qt qml qtquick2 qqmlcomponent