Qt 当我在qml中为ListView应用LayoutMirroring时,在触摸屏幕之前,我的屏幕是空的
当我在qml中为ListView应用LayoutMirroring时,在触摸屏幕之前,我的屏幕是空的Qt 当我在qml中为ListView应用LayoutMirroring时,在触摸屏幕之前,我的屏幕是空的,qt,Qt,当我在qml中为ListView应用LayoutMirroring时,在触摸屏幕之前,我的屏幕是空的 import QtQuick 1.1 Item { id:idWifiNamePasswordPage objectName: "WifiNameAndPasswordPage" width: deviceScreenWidth height: deviceScreenHeight LayoutMirroring.enabled: m
import QtQuick 1.1
Item {
id:idWifiNamePasswordPage
objectName: "WifiNameAndPasswordPage"
width: deviceScreenWidth
height: deviceScreenHeight
LayoutMirroring.enabled: main.layoutMirroring
LayoutMirroring.childrenInherit: main.layoutMirroring
property variant viewClass: AppsProvider.appsList[main.qtEnums.QT_DEVUI_APP_WIFI]
property bool displaySettings : (viewClass.WifiSettingDisplayUiEnabled == 1) ? true : false
property string wifiSsid: viewClass.WifiSsid
property string guestWifiSsid: viewClass.GuestWifiSsid
property string wifiKey: viewClass.WifiKey
property string guestWifiKey: viewClass.GuestWifiKey
property alias idWifiNamePasswordModel: idWifiNamePasswordModel
property alias idListView: idListView
property alias pager: pager
property string headerTitle: mainModel.GetPOText("wifi_name_password_text")
property string wifiLabel: mainModel.GetPOText("wifi_settings_label")
property int selectedIndex:0
property bool primaryWifiEnable: (main.wifiEnable && main.wifiNetworkStatus) ? true : false
property bool guestWifiEnable: (main.wifiEnable && main.guestNetworkStatus) ? true : false
property bool showPrimaryWifiOffText: (main.wifiEnable && !main.wifiNetworkStatus) ? true : false
property bool showGuestWifiOffText: (main.wifiEnable && !main.guestNetworkStatus) ? true : false
property string primaryWifiText: (primaryWifiEnable == true) ? mainModel.GetPOText("wifi_primary_network_on_text") : mainModel.GetPOText("wifi_primary_network_off_text")
property string guestWifiText: (guestWifiEnable == true) ? mainModel.GetPOText("wifi_guest_network_on_text") : mainModel.GetPOText("wifi_guest_network_off_text")
property string wifiText: mainModel.GetPOText("wifi_set_name_password_text")
property string primaryWifiOffText: mainModel.GetPOText("wifi_primary_off_text")
property string guestWifiOffText: mainModel.GetPOText("wifi_guest_off_text")
property string wifiPrimaryNameText: mainModel.GetPOText("WiFi_Primary_Name_text")
property string wifiGuestNameText: mainModel.GetPOText("WiFi_Guest_Name_text")
property string wifiPasswordText: mainModel.GetPOText("WiFi_Password")
property string wifiSetNamePasswdHelpText: mainModel.GetPOText("wifi_set_name_password_help_text").arg(main.domainUrl).arg(main.adminKey)
function refreshUI(mainId) {
if (mainId.activeQmlFile == "WifiNameAndPasswordPage.qml") {
console.log("In WifiNameAndPasswordPage -- refreshUI")
mainId.activeQmlId.headerTitle= mainId.getPoText("wifi_name_password_text", "")
mainId.activeQmlId.wifiLabel= mainId.getPoText("wifi_settings_label", "")
mainId.activeQmlId.primaryWifiText= (mainId.activeQmlId.primaryWifiEnable == true) ?
mainId.getPoText("wifi_primary_network_on_text", "") : mainId.getPoText("wifi_primary_network_off_text", "")
mainId.activeQmlId.guestWifiText= (mainId.activeQmlId.guestWifiEnable == true) ?
mainId.getPoText("wifi_guest_network_on_text", "") : mainId.getPoText("wifi_guest_network_off_text", "")
mainId.activeQmlId.wifiText= mainId.getPoText("wifi_set_name_password_text", "")
mainId.activeQmlId.primaryWifiOffText= mainId.getPoText("wifi_primary_off_text", "")
mainId.activeQmlId.guestWifiOffText= mainId.getPoText("wifi_guest_off_text", "")
mainId.activeQmlId.wifiPrimaryNameText= mainId.getPoText("WiFi_Primary_Name_text", "")
mainId.activeQmlId.wifiGuestNameText= mainId.getPoText("WiFi_Guest_Name_text", "")
mainId.activeQmlId.wifiPasswordText= mainId.getPoText("WiFi_Password", "")
mainId.activeQmlId.wifiSetNamePasswdHelpText= mainId.getPoText("wifi_set_name_password_help_text",[mainId.domainUrl,mainId.adminKey])
loadWifiNamePasswordModel(mainId, mainId.activeQmlId)
mainId.activeQmlId.idListView.positionViewAtIndex(mainId.activeQmlId.selectedIndex , ListView.Beginning)
}
}
BaseHeader {
id: baseheader
title: headerTitle
}
ListModel {
id: idWifiNamePasswordModel
}
ListView {
id: idListView
anchors.top: baseheader.bottom
width: parent.width
height: deviceScreenHeight - baseheader.height
clip: true
orientation: ListView.Horizontal
snapMode: ListView.SnapOneItem
highlightRangeMode: ListView.StrictlyEnforceRange
highlightFollowsCurrentItem: true
highlightMoveSpeed: main.horizontalScrollingSpeed
highlightMoveDuration: 200
model: idWifiNamePasswordModel
delegate: Rectangle {
id: idWifinfo
width: idListView.width
height: parent.height - bottomPanel.height - (((wifiType === "primary") ? primaryWifiEnable : guestWifiEnable) ? 0 : ((showWifiInfo) ? separator.height+idwifiNetworkText.height : 0) )
CFlickable {
id: flickarea
anchors.fill: parent
flickableWidth: parent.width
flickableHeight: parent.height
flickableContentWidth: parent.width
flickableContentHeight: idTitleRow.height + wifiName.paintedHeight + idWifiSsid.paintedHeight + wifiPassword.height + wifipwd.paintedHeight + 50 //50 = adding all top margins
Rectangle {
id: idTitleRow
anchors.top: parent.top
anchors.topMargin: 2*main.topMargin - 5
anchors.left: parent.left
anchors.leftMargin: main.leftMargin - 5
Image {
id:wifiIcon
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
source: (wifiType === "none") ? "" : (((wifiType === "primary") ? primaryWifiEnable : guestWifiEnable) ? main.qtImages.QT_DEVUI_IMAGE_HOME_WIFI_ON : main.qtImages.QT_DEVUI_IMAGE_HOME_WIFI_OFF)
mirror: main.layoutMirroring
}
Text {
id: idTitle
anchors.left: wifiIcon.right
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: pixelSize
elide: Text.ElideRight
text: wifiTitle
}
}
Text {
id: wifiName
width: parent.width - rightMargin
anchors.top: idTitleRow.bottom
anchors.topMargin: main.topMargin + 5
anchors.left: parent.left
anchors.leftMargin: main.leftMargin - 5
anchors.right: parent.right
anchors.rightMargin: main.rightMargin - 5
horizontalAlignment: Text.AlignLeft
text: ssidLabel
font.pixelSize: pixelSize
wrapMode: Text.Wrap
Component.onCompleted: {
console.log("In wifiname")
flickarea.flickableContentHeight = idTitleRow.height + wifiName.paintedHeight + idWifiSsid.paintedHeight + wifiPassword.height + wifipwd.paintedHeight + 50 //50 = adding all top margins
console.log("Flickarea Height:[" + flickarea.flickableHeight + "], ContenetHeight:[" + flickarea.flickableContentHeight + "]")
}
}
Text {
id: idWifiSsid
visible: showWifiInfo
anchors.top: wifiName.bottom
anchors.topMargin: main.topMargin - 5
anchors.left: parent.left
anchors.leftMargin: main.leftMargin - 5
anchors.right: parent.right
anchors.rightMargin: main.rightMargin - 5
width: parent.width - rightMargin
text: ssid
horizontalAlignment: Text.AlignLeft
wrapMode: Text.Wrap
font.pixelSize: pixelSize
Component.onCompleted: {
console.log("In wifissid")
flickarea.flickableContentHeight = idTitleRow.height + wifiName.paintedHeight + idWifiSsid.paintedHeight + wifiPassword.height + wifipwd.paintedHeight + 50 //50 = adding all top margins
console.log("Flickarea Height:[" + flickarea.flickableHeight + "], ContenetHeight:[" + flickarea.flickableContentHeight + "]")
}
}
Text {
id: wifiPassword
visible: showWifiInfo
width: parent.width - rightMargin
anchors.top: idWifiSsid.bottom
anchors.topMargin: main.topMargin - 5
anchors.left: parent.left
anchors.leftMargin: main.leftMargin - 5
anchors.right: parent.right
anchors.rightMargin: main.rightMargin - 5
horizontalAlignment: Text.AlignLeft
text: passwdLabel
font.pixelSize: pixelSize
wrapMode: Text.Wrap
Component.onCompleted: {
console.log("In wifipassword")
flickarea.flickableContentHeight = idTitleRow.height + wifiName.paintedHeight + idWifiSsid.paintedHeight + wifiPassword.height + wifipwd.paintedHeight + 50 //50 = adding all top margins
console.log("Flickarea Height:[" + flickarea.flickableHeight + "], ContenetHeight:[" + flickarea.flickableContentHeight + "]")
}
}
Text {
id: wifipwd
visible: showWifiInfo
anchors.top: wifiPassword.bottom
anchors.topMargin: main.topMargin - 5
anchors.left: parent.left
anchors.leftMargin: main.leftMargin - 5
anchors.right: parent.right
anchors.rightMargin: main.rightMargin - 5
width: parent.width - rightMargin
text: passwd
horizontalAlignment: Text.AlignLeft
wrapMode: Text.Wrap
font.pixelSize: pixelSize
Component.onCompleted: {
console.log("In wifipwd")
flickarea.flickableContentHeight = idTitleRow.height + wifiName.paintedHeight + idWifiSsid.paintedHeight + wifiPassword.height + wifipwd.paintedHeight + 50 //50 = adding all top margins
console.log("Flickarea Height:[" + flickarea.flickableHeight + "], ContenetHeight:[" + flickarea.flickableContentHeight + "]")
}
}
} //End Flickable
} //end delegate
onCurrentIndexChanged: {
console.log("onCurrentIndexChanged [" + currentIndex + "]")
pager.selected = currentIndex
setHelpText(currentIndex, idWifiNamePasswordPage)
}
// Bottom area
Rectangle {
id: bottomPanel
anchors.bottom: parent.bottom
width: deviceScreenWidth
height: deviceScreenHeight/24
PageIndicator {
id: pager
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
height: parent.height
totalCount: idListView.model.count
}
}
// Thin line
Rectangle {
id: separator
visible: ((selectedIndex === 0 && !primaryWifiEnable) || (selectedIndex === 1 && !guestWifiEnable)) ? true : false
anchors.bottom: idwifiNetworkText.top
width: deviceScreenWidth
height: 1
color: main.gridLineColor
}
Text {
id: idwifiNetworkText
width: deviceScreenWidth - leftMargin - rightMargin
height: deviceScreenHeight/5
visible: ((selectedIndex === 0 && !primaryWifiEnable) || (selectedIndex === 1 && !guestWifiEnable)) ? true : false
anchors.left: parent.left
anchors.leftMargin: main.leftMargin - 5
anchors.right: parent.right
anchors.rightMargin: main.rightMargin - 5
anchors.bottom: bottomPanel.top
text: (selectedIndex === 0) ? primaryWifiOffText : (selectedIndex === 1) ? guestWifiOffText : ""
font.pixelSize: pixelSize-1
wrapMode: Text.Wrap
}
} //end ListView
function setHelpText(index, refObj) {
height = 0
if(index == 0) {
separator.visible = false
idwifiNetworkText.visible = false
if(!refObj.primaryWifiEnable) {
separator.visible = true
idwifiNetworkText.visible = true
idwifiNetworkText.text = refObj.primaryWifiOffText
height = idwifiNetworkText.height
}
} else if(index == 1) {
separator.visible = false
idwifiNetworkText.visible = false
if(!refObj.guestWifiEnable) {
separator.visible = true
idwifiNetworkText.visible = true
idwifiNetworkText.text = refObj.guestWifiOffText
height = idwifiNetworkText.height
}
} else if(index == 2) {
separator.visible = false
idwifiNetworkText.visible = false
idwifiNetworkText.text = ""
}
}
function loadWifiNamePasswordModel(mainId, refObj) {
console.log("In Wifi name and password screen - loading model")
refObj.idWifiNamePasswordModel.clear()
refObj.idWifiNamePasswordModel.append({"wifiType": "primary", "wifiTitle": refObj.primaryWifiText, "ssidLabel": refObj.wifiPrimaryNameText, "passwdLabel": refObj.wifiPasswordText, "ssid": refObj.wifiSsid, "passwd": refObj.wifiKey, "helpText": "", "showWifiInfo": true})
refObj.idWifiNamePasswordModel.append({"wifiType": "guest", "wifiTitle": refObj.guestWifiText, "ssidLabel": refObj.wifiGuestNameText, "passwdLabel": refObj.wifiPasswordText, "ssid": refObj.guestWifiSsid, "passwd": refObj.guestWifiKey, "helpText": "", "showWifiInfo": true})
refObj.idWifiNamePasswordModel.append({"wifiType": "none", "wifiTitle": refObj.wifiText, "ssidLabel": refObj.wifiSetNamePasswdHelpText, "passwdLabel": "", "ssid": "", "passwd": "", "helpText": refObj.wifiSetNamePasswdHelpText, "showWifiInfo": false})
}
Component.onCompleted: {
main.activeQmlId = idWifiNamePasswordPage
loadWifiNamePasswordModel(main, idWifiNamePasswordPage)
console.log("WifiNameAndPasswordPage.qml loaded successfully")
if (!main.isScreenAlreadyLoaded(main.qtEnums.QT_DEVUI_APP_WIFI, "WifiNameAndPasswordPage.qml")) {
main.languageUpdated.connect(refreshUI)
}
}
}
你有太多不相关的代码。将您的示例简化为演示问题所需的内容。这就是我们所说的a。