Row{ width: childrenRect.width spacing: 5 CusLabel{ id:dateTimeLabel text: "筛选时间" font.pixelSize: 16 anchors.verticalCenter: dateInput.verticalCenter } CusInputDate{ id:dateInput height: 20 normalTextColor: CusConfig.themeColor selectTextColor: CusConfig.pageBkgColor beginDate: __minDate endDate: new Date() endTime: Qt.formatDateTime(new Date(),"hh:mm:ss") Component.onCompleted: { __minDate= new Date("2020/01/01") __maxDate= new Date() } } } } 这段代码中将时间筛选两个日期分为3行显示
时间: 2024-03-30 20:33:19 浏览: 19
这段代码中并没有将时间筛选两个日期分为3行显示,而是将它们放在一个Row中并用两个子组件显示。第一个子组件是一个CusLabel,用于显示"筛选时间"这个文本,第二个子组件是一个CusInputDate,用于显示日期的输入框。这两个子组件之间的间距为5。所以整个Row的高度只有两个子组件的高度加上间距。
相关问题
Rectangle{ width: parent.width height: 120/2 anchors.bottom: parent.bottom color: "#114670" Row{ width: childrenRect.width spacing: 5 CusLabel{ id:dateTimeLabel text: "筛选时间" font.pixelSize: 16 anchors.verticalCenter: dateInput.verticalCenter } CusInputDate{ id:dateInput height: 20 normalTextColor: CusConfig.themeColor selectTextColor: CusConfig.pageBkgColor beginDate: __minDate endDate: new Date() endTime: Qt.formatDateTime(new Date(),"hh:mm:ss") Component.onCompleted: { __minDate= new Date("2020/01/01") __maxDate= new Date() } } } } 这段代码中将时间筛选两个日期分为两行
可以将 `Row` 换成 `Column`,这样就可以将两个控件分开放在不同的行了,代码修改如下:
```
Rectangle{
width: parent.width
height: 120/2
anchors.bottom: parent.bottom
color: "#114670"
Column{
width: childrenRect.width
spacing: 5
CusLabel{
id:dateTimeLabel
text: "筛选时间"
font.pixelSize: 16
anchors.horizontalCenter: parent.horizontalCenter
}
CusInputDate{
id:dateInput
height: 20
normalTextColor: CusConfig.themeColor
selectTextColor: CusConfig.pageBkgColor
beginDate: __minDate
endDate: new Date()
endTime: Qt.formatDateTime(new Date(),"hh:mm:ss")
Component.onCompleted: {
__minDate= new Date("2020/01/01")
__maxDate= new Date()
}
}
}
}
```
qml中listview中插入可折叠项,代码
如下:
```
ListView {
model: myModel
delegate: collapsibleItem
Component {
id: collapsibleItem
Item {
property bool isExpanded: false
property variant itemData: modelData
width: parent.width
height: isExpanded ? childrenRect.height : 30
Rectangle {
width: parent.width
height: 30
color: "lightblue"
Text {
text: itemData.name
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
onClicked: {
isExpanded = !isExpanded
}
}
}
Rectangle {
width: parent.width
height: isExpanded ? childrenRect.height : 0
color: "lightgrey"
ListView {
anchors.fill: parent
model: itemData.children
delegate: Text {
text: modelData.name
}
}
}
}
}
}
```
其中myModel包含一个name和children两个属性,children为列表中的子项。可折叠项由一个外部矩形和一个内部矩形组成,内部矩形包含一个ListView,用于显示子项。点击外部矩形时,内部矩形的高度会根据是否展开改变。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![xlsx](https://img-home.csdnimg.cn/images/20210720083732.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pptx](https://img-home.csdnimg.cn/images/20210720083543.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![xlsx](https://img-home.csdnimg.cn/images/20210720083732.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)