我的QML ApplicationWindow
名为ueWindowMain
,并在main.qml
中声明。其中包含名为StatusBar
的QML ueStatusBar
,其中包含两个名为ueStatusIndicatorDatabaseConnected
和ueStatusIndicatorBluetoothPrinterConnected
的图标,显示一些状态和一个可检查的QML Button
,名为{{1} }}:
ueStaffSelector
现在,import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.0
import QtQuick.Controls.Styles 1.4
import si.mikroelektronika 1.0
import "gui/items"
ApplicationWindow
{
id: ueWindowMain
title: qsTr("uBlagajna Mobile Client ver 0 revision 101")
width: Screen.desktopAvailableWidth
height: Screen.desktopAvailableWidth
visible: true
opacity: 1.0
contentOrientation: Qt.LandscapeOrientation
color: "black"
statusBar: StatusBar
{
id: ueStatusBar
height: 96
clip: true
antialiasing: true
style: StatusBarStyle
{
background: Rectanglstrong texte
{
width: parent.width
height: parent.height
color: "#303030"
} // background
} // style
RowLayout
{
spacing: 8
UeDatabaseStatusIndicator
{
id: ueStatusIndicatorDatabaseConnected
Layout.minimumWidth: 96
Layout.preferredWidth: 96
Layout.maximumWidth: 96
Layout.fillHeight: true
ueParamImageStatusOn: "qrc:///ueIcons/icons/ueDbConnectionOk.png"
ueParamImageStatusOff: "qrc:///ueIcons/icons/ueDbConnectionError.png"
} // ueStatusIndicatorDatabaseConnected
UeBluetoothStatusIndicator
{
id: ueStatusIndicatorBluetoothPrinterConnected
Layout.minimumWidth: 96
Layout.preferredWidth: 96
Layout.maximumWidth: 96
Layout.fillHeight: true
ueParamImageStatusOn: "qrc:///ueIcons/icons/ueBtConnectionOk.png"
ueParamImageStatusOff: "qrc:///ueIcons/icons/ueBtConnectionError.png"
} // ueStatusIndicatorBluetoothPrinterConnected
UeStaffSelector
{
id: ueStaffSelector
Layout.minimumWidth: 96
Layout.preferredWidth: 96
Layout.maximumWidth: 96
Layout.fillHeight: true
} // ueStaffSelector
} // RowLayout
} // ueStatusBar
} // ueWindowMain
中的这三个项目使用StatusBar
定位。如何在QML代码中计算它们的坐标,即以编程方式计算?
答案 0 :(得分:0)
我设法通过以下代码块来解决问题:
x: ueStatusIndicatorDatabaseConnected.width+
ueStatusIndicatorBluetoothPrinterConnected.width+2*ueStatusBarLayout.spacing
y: ueWindowMain.height-ueStatusBar.height-ueStaffView.height
现在它似乎工作正常。