查看完整版本: [-- 为什么gridlayouts超边界?? --]

QTCN开发网 -> Qt QML开发 -> 为什么gridlayouts超边界?? [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

lovexin109 2017-09-12 10:44

为什么gridlayouts超边界??

  1. Window {
        visible: true
        width: 360
        height: 640
        title: qsTr("Hello World")

        GridLayout{

            anchors.left: parent.left

            columns: 9
            rows:16
            columnSpacing: 1
            rowSpacing: 1
            Label {
                text: qsTr("Type  :")
                Layout.column: 0
                Layout.row: 0
                Layout.columnSpan: 1
            }
            ComboBox{
                id:linearchoose
                Layout.row:0
                Layout.column: 1
                Layout.columnSpan: 8
                Layout.fillWidth: true

                textRole :"com_text"
                model: ListModel{
                    ListElement{com_text:"default";min_scale:"0";max_scale:"100"}
                    ListElement{com_text:"s7-200(0~32000)";min_scale:"0";max_scale:"32000"}

                }
                onActivated: {
                    linearchoose.currentIndex=index

                    text_inmin.text=model.get(index).min_scale
                    text_inmax.text=model.get(index).max_scale

                }
            }

            Label {
                text: qsTr("Input :")
                Layout.row: 1
                Layout.column: 0
            }
            TextField {
                id:text_inmin
                placeholderText: "0"
                Layout.row: 1
                Layout.column: 1
                Layout.columnSpan: 3
            }
            TextField {
                id:text_inmax
                placeholderText: "100"
                Layout.row: 1
                Layout.column: 4
                Layout.columnSpan: 3
            }



            Label {
                text: qsTr("Output:")
                Layout.row: 2
                Layout.column: 0
            }
            TextField {
                id:text_outmin
                placeholderText: "0"
                Layout.row: 2
              Layout.column: 1
                Layout.columnSpan: 3
            }
            TextField {
                id:text_outmax
                placeholderText: "100"
                Layout.row: 2
                Layout.column: 4
                Layout.columnSpan: 3

            }

            Button{

                id:changebutton
                Layout.row: 1
                Layout.column: 7
                Layout.rowSpan: 2
                Layout.columnSpan: 2
                Layout.fillHeight: true
                Layout.fillWidth: true

            }

    }
    }

显示如下图:右侧还没显示全
[attachment=17842]



拉窗口拉大才显示全
[attachment=17844]

想请教下为什么gridlayouts超出边界


never_forget 2017-09-12 11:17
你有设置这个布局的大小吗 ?貌似只是设置了左对齐,可以使用 anchors.fill: parent,也可以指定长宽,试试看!

lovexin109 2017-09-12 15:19
never_forget:你有设置这个布局的大小吗 ?貌似只是设置了左对齐,可以使用 anchors.fill: parent,也可以指定长宽,试试看! (2017-09-12 11:17) 

试过了,anchors.parent,整个布局都会乱,而且中间还不能间隔,不能完全按格子放,想空一格都空不了,很奇怪这种布局,可能是我没理解这个布局


查看完整版本: [-- 为什么gridlayouts超边界?? --] [-- top --]



Powered by phpwind v8.7 Code ©2003-2011 phpwind
Gzip disabled