Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt 如何多次设置Layout.alignment?_Qt_Qml - Fatal编程技术网

Qt 如何多次设置Layout.alignment?

Qt 如何多次设置Layout.alignment?,qt,qml,Qt,Qml,如何在Rowlayout或ColumnLayout中居中放置一个元素,并使它们保持有序,以便无论第一个对象的比例如何,第二个对象始终位于它之后 ColumnLayout { id: currentMusicRow anchors.horizontalCenterOffset: wrapper.width / -4.5 anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top

如何在Rowlayout或ColumnLayout中居中放置一个元素,并使它们保持有序,以便无论第一个对象的比例如何,第二个对象始终位于它之后

 ColumnLayout {
    id: currentMusicRow
    anchors.horizontalCenterOffset: wrapper.width / -4.5
    anchors.horizontalCenter: parent.horizontalCenter
    anchors.top: parent.top
    anchors.topMargin: 20


    Rectangle {
        id: currentPicBackground
        x: 273
        y: 20
        width: 260
        height: 260
        color: "#151515"
        Layout.alignment: parent.AlignHCenter

        Image {
            id: currentMusicPic
            x: 2
            y: 2
            anchors.fill: parent
            anchors.margins: 2
            source: "images/maxresdefault.jpg"
            fillMode: Image.Stretch
        }
    }

    RowLayout {
        id: titleMusicLayout
        width: 222
        height: 29
        Layout.horizontalCenter: parent.AlignCenter
        Layout.bottomMargin: -50
        Layout.bottom: currentPicBackground.AlignBottom

        Text {
            id: band
            width: 155
            height: 28
            color: "#f2f2f2"
            text: qsTr("Glad Boris")
            font.italic: false
            font.weight: Font.Medium
            style: Text.Normal
            font.underline: false
            font.family: "Acme"
            font.bold: false
            font.pixelSize: 22
            MouseArea {
                id: bandMouseArea
                width: 123
                height: 28
                anchors.centerIn: parent
                hoverEnabled: true
            }
        }

        Text {
            id: diveder
            width: 13
            height: 28
            color: "#f2f2f2"
            text: "/"
            font.bold: false
            font.pixelSize: 22
            font.family: "Tahoma"
        }

        Text {
            id: musicName
            width: 103
            height: 28
            color: "#f2f2f2"
            text: "relaxation"
            font.weight: Font.Light
            font.bold: false
            font.pixelSize: 20
            font.family: "Acme"

            MouseArea {
                id: musicNameMouseArea
                width: 103
                height: 28
                anchors.centerIn: parent
                hoverEnabled: true
            }
        }

它显示了一个错误,因为我多次设置了对齐方式,但我需要以某种方式使文本(行内布局)低于矩形/图像(列内布局),即使图像放大得更大(文本必须固定在底部)。

没有类似于
parent.AlignHCenter的东西,这应该是一个或几个标志。你说多次设置布局对齐是什么意思?请提供一些图片,你想要什么,得到什么。我需要知道如何在Rowlayout或ColumnLayout中心放置一个元素,并使它们保持有序,这样无论第一个对象的比例如何,第二个对象总是在它之后。@AndrewO'Brien在这种情况下,最好放置一个你得到什么和你想要得到什么的图像。你不能做我认为你想要的事情布局<代码>行布局
仅允许垂直居中,而
列布局
仅允许水平居中(换句话说:垂直于布局方向)。无论如何,你应该使用。我想要的是“Layout.alignment:Qt.AlignHCenter | Qt.AlignVCenter | Qt.AlignBottom”将多个值设置为Layout.alignment