QML ProgressBar';s垂直方向在100%时不填充到顶部
在QMLQML ProgressBar';s垂直方向在100%时不填充到顶部,qml,Qml,在QMLmain窗口中,我有滑块和ProgressBar: import QtQuick 2.5 import QtQuick.Controls 1.4 import QtQuick.Layouts 1.1 import QtQuick.Window 2.2 ApplicationWindow { visible: true width: Screen.width/2 height: Screen.height/2 opacity: 1.00 co
main窗口中,我有滑块和ProgressBar
:
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.1
import QtQuick.Window 2.2
ApplicationWindow
{
visible: true
width: Screen.width/2
height: Screen.height/2
opacity: 1.00
color: "black"
RowLayout
{
anchors.fill: parent
Slider
{
id: ueSlider
Layout.fillWidth: true
Layout.fillHeight: true
Layout.margins: 8
Layout.alignment: Qt.AlignLeft|Qt.AlignVCenter
activeFocusOnPress: false
tickmarksEnabled: false
minimumValue: 0
maximumValue: 100
stepSize: 1
orientation: Qt.Vertical
onValueChanged:
{
ueProgressBar.value=value;
} // onValueChanged
} // Slider
ProgressBar
{
id: ueProgressBar
Layout.fillWidth: true
Layout.fillHeight: true
Layout.margins: 8
Layout.alignment: Qt.AlignRight|Qt.AlignVCenter
orientation: Qt.Vertical
indeterminate: false
onValueChanged:
{
print("ProgressBar value: "+value);
} // onValueChanged
Component.onCompleted:
{
minimumValue=ueSlider.minimumValue;
maximumValue=ueSlider.maximumValue;
value=ueSlider.value;
} // Component.onCompleted
} // ProgressBar
} // RowLayout
} // ApplicationWindow
现在,ProgressBar
已“连接”到滑块
——当我更改滑块
的值时,ProgressBar
的值
会更改。如果我将ProgressBar
的方向更改为Qt.Horizontal
,一切正常,但是如果我将其方向更改为Qt.Vertical
,运行示例并将滑块推到顶部(推到其最大值),则ProgressBar
不会转到100%
:
为什么 可能是重力的作用吗?:-)不,@skypjack发生这种情况是因为右括号中的注释。;-)但说真的,我已经在LinuxKDE和Windows7上测试过了,一切都正常。尝试玩ProgressBar.maximumValue
和ProgressBar.minimumValue
。默认情况下,ProgressBar.maximumValue
为1,而不是100@folibisProgressBar.maximumValue
设置在completed.onCompleted
@KernelPanic您无法保证在进度条的onCompleted
时,滑块也已完成。尝试将这些操作移动到父组件的onCompleted
中。