页脚项目 qml 问题

问题描述 投票:0回答:0

我只是一个初学者,我正在尝试为我的学校项目构建一个应用程序,所以我想做的是:

  • 首先我使用 footer 属性将我的按钮放在它上面但是当我尝试做左边距以获得与我的左按钮相同的 culumn 我没有结果
  • 当我尝试双击我的窗口时,我遇到了同样的问题,我的左键留出了太多空间 enter image description hereenter image description here

main.qml

import QtQuick 2
import QtQuick.Controls 2.15
import QtQuick.Controls.Material 2.15
import QtQuick.Layouts



ApplicationWindow {
    id: applicationWindow
    property string displayedButton: ""
    width: 800
        height: 380
    visible: true

    Page {
        anchors.fill: parent
        id:page

        RowLayout {
            id:rec
            anchors.fill: parent


            ListView {
                anchors.topMargin: 20
                y:10
                id: leftMenuBar
                Layout.preferredWidth: 90
                Layout.fillHeight: true
                clip: true
                spacing: 10
                Repeater {
                    model: 3
                    delegate: Button{
                        implicitHeight: 90
                        implicitWidth: 90
                        text: "Button " + (index + 1)
                        onClicked: displayedButton = text



                        Layout.alignment: Qt.AlignHCenter // must be set to align the rectangles within their empty space
                    }
                }

                Layout.alignment: Qt.AlignLeft
                Layout.leftMargin: 20
            }

            Item {
                Layout.fillWidth: true
                Layout.fillHeight: true

                Rectangle {
                    anchors.fill: parent
                    anchors.margins: 12
                    border.width: 2
                    border.color: "lightgray"
                    radius: 35

                    Text {
                        anchors.centerIn: parent
                        text: "Selected Button: " + displayedButton
                        font.pixelSize: 20
                    }
                }
            }

        }
        footer:RowLayout {
            width: 500



            Repeater {
                model: 8
                delegate: Button{
                    implicitHeight: 90
                    implicitWidth: 90
                    text: "Button " + (index + 1)
                    onClicked: displayedButton = text



                    Layout.alignment: Qt.AlignHCenter // must be set to align the rectangles within their empty space
                }
            }
        }






    }

}


















enter code here
qt qml
© www.soinside.com 2019 - 2024. All rights reserved.