尝试在 Ubuntu 上的对话框中创建两个选择器时,其中的标签只有在未被选中时才能正确读取,而被选中时则会在左侧重叠,如图所示:
对话框的代码:
import QtQuick 2.0
import Ubuntu.Components 1.1
import Ubuntu.Components.Pickers 1.0
import Ubuntu.Components.Popups 1.0
Component {
id: dialogComponent
Dialog {
id: dialog
objectName: "dialog"
HospitalsModel {
id: hospitalsModel
objectName: "hospitals_model"
}
PrimaryCenterModel {
id: primaryCenterModel
objectName: "primaryCenter_model"
}
title: i18n.tr("Configuration")
text: i18n.tr("Please, choose your hospital and primary center")
Picker {
id: hospitalPicker
objectName: "hospitalPicker"
model: hospitalsModel
delegate: PickerDelegate {
Label {
fontSize: "x-small"
text: name
}
}
}
Picker {
id: primaryCenterPicker
objectName: "primaryCenterPicker"
model: primaryCenterModel
delegate: PickerDelegate {
Label {
fontSize: "x-small"
text: name
}
}
}
Button {
id: okBtn
objectName: "okBtn"
text: i18n.tr("OK")
onClicked: PopupUtils.close(dialog)
}
}
}
医院模式:
import QtQuick 2.0
ListModel {
ListElement {
name: "Hospital El Bierzo"
url: "http://www.saludcastillayleon.es/HBierzoPonferrada/es"
}
ListElement {
name: "Hospital Serranía Ronda"
url: "http://www.malagasalud.es/hospitales-publicos-en-malaga/hospital-serrania-ronda-area-sanitaria-serrania-malaga,112.html"
}
}
初级中心模型:
import QtQuick 2.0
ListModel {
ListElement {
name: "Centro de Salud 2, Pico Tuerto"
url: "http://www.jcyl.es/web/jcyl/Portada/es/Plantilla100Directorio/1248366924958/0/1142233519857/DirectorioPadre"
}
ListElement {
name: "Centro de Salud Ronda-Sur, Santa Bárbara"
url: "http://www.juntadeandalucia.es/servicioandaluzdesalud/centros/detalle.asp?IdCentro=24967"
}
}
有没有办法解决这个问题,以便选定的标签可读?
答案1
这与对话框无关,无论在何处、何种情况下使用,都会遇到同样的问题。
从代码中我看到你正在使用一个圆形 Picker,它使用 PathView 来可视化模型。PathView 根据模型中的数据量来拉伸委托,从而产生你看到的行为。尝试将圆形设置为 false,我相信视觉效果会很好。