Qml 子窗体设计

import QtQuick 2.14
import QtQuick.Window 2.14
import QtQuick.Controls 1.4

Window {
    visible: true
    title: qsTr("Hello World")
    minimumWidth: 640
    maximumWidth: 640
    minimumHeight: 260
    maximumHeight: 260
/*
    Window {
        id: inletSettingPanel
        title: "新窗口"
        minimumWidth: 270; minimumHeight: 660
    }

    Button
    {
        x: parent.x
        y: parent.y
        width: contentItem.width
        height: 15
        activeFocusOnTab: false
        text: "打开新窗口"

        //可在此类中设置需要显示的窗口的大小等属性
        onClicked:
        {
            inletSettingPanel.show();
        }
    }
*/
/*
    Window{
        id: _sub
        width: 300
        height: 300
        color: Qt.lighter("gray")
        title: qsTr("这是子窗口")
    }
    Button{
        text: "子窗口"
        onClicked: _sub.visible=!_sub.visible
    }
*/
    Loader{
        id:loader
    }

    Component {
        id: _sub

        Window {
            id: win
            title: "sub Window"

            minimumWidth: 550
            maximumWidth: 550
            minimumHeight: 400
            maximumHeight: 400
            visible: true
            color: "gray"
            // ApplicationModal: 模态
            modality: Qt.NonModal   /// 非模态
            MouseArea {
                anchors.fill: parent
                onClicked: close();
            }

            Connections {
                target: win
                onClosing: {
                    loader.sourceComponent = undefined;
                }
            }

            Rectangle {
                id: _rightUp

                width: 50
//                height: 100
//                width: parent.width/2
                height: parent.height/2
                anchors.left: parent.left
                anchors.leftMargin: 10
                anchors.top: parent.top
                anchors.topMargin: 10

                color: "red"
            }

            Rectangle {
                id: _rightDown

                width: 50
//                height: 100
//                width: parent.width/2
                height: _ex.height
                anchors.left: parent.left
                anchors.leftMargin: 10
                anchors.top: _rightUp.bottom
                anchors.topMargin: 10
                anchors.bottom: parent.bottom
                anchors.bottomMargin: 10

                color: "red"
            }

            Grid {
                id: _ex

                spacing: 20
                anchors.top: parent.top
                anchors.topMargin: 20
                anchors.left: _rightUp.right
                anchors.leftMargin: 10
                anchors.bottom: _rightUp.bottom
                anchors.bottomMargin: 20
                rows: 4
                columns: 4

                // 1
                Label {
                    id: _lable1
                    font.pixelSize: 22
                    font.italic: true
                    text: qsTr("par1")
                }

                TextField {
                    id: _lable1value
                    text: qsTr("20.01")
                }
                Label {
                    id: _lable2
                    font.pixelSize: 22
                    font.italic: true
                    text: qsTr("par2")
                }

                TextField {
                    id: _lable2value
                    text: qsTr("20.02")
                }

                // 2
                Label {
                    id: _lable11
                    font.pixelSize: 22
                    font.italic: true
                    text: qsTr("par1")
                }

                TextField {
                    id: _lable11value
                    text: qsTr("20.01")
                }
                Label {
                    id: _lable12
                    font.pixelSize: 22
                    font.italic: true
                    text: qsTr("par2")
                }

                TextField {
                    id: _lable12value
                    text: qsTr("20.02")
                }
                // 3
                Label {
                    id: _lable21
                    font.pixelSize: 22
                    font.italic: true
                    text: qsTr("par1")
                }

                TextField {
                    id: _lable21value
                    text: qsTr("20.01")
                }
                Label {
                    id: _lable22
                    font.pixelSize: 22
                    font.italic: true
                    text: qsTr("par2")
                }

                TextField {
                    id: _lable22value
                    text: qsTr("20.02")
                }
                // 4
                Label {
                    id: _lable31
                    font.pixelSize: 22
                    font.italic: true
                    text: qsTr("par1")
                }

                TextField {
                    id: _lable31value
                    text: qsTr("20.01")
                }
                Label {
                    id: _lable32
                    font.pixelSize: 22
                    font.italic: true
                    text: qsTr("par2")
                }

                TextField {
                    id: _lable32value
                    text: qsTr("20.02")
                }
            }

            Button {
                id: _okButton

                text: qsTr("发送")
                anchors.top: parent.top
                anchors.topMargin: 10
                anchors.left: _ex.right
                anchors.leftMargin: 30

                height: _ex.height
                onClicked: {
                    console.log("begin to send")
                }
            }


            Grid {
                id: _ey

                spacing: 20
                anchors.top: _rightDown.top
                anchors.topMargin: 10
                anchors.left: _rightDown.right
                anchors.leftMargin: 10
                anchors.bottom: _rightDown.bottom
                anchors.bottomMargin: 10
                rows: 4
                columns: 4

                // 1
                Label {
                    id: _lableRD1
                    font.pixelSize: 22
                    font.italic: true
                    text: qsTr("par1")
                }

                TextField {
                    id: _lableRD1value
                    text: qsTr("20.01")
                }
                Label {
                    id: _lableRD2
                    font.pixelSize: 22
                    font.italic: true
                    text: qsTr("par2")
                }

                TextField {
                    id: _lableRD2value
                    text: qsTr("20.02")
                }

                // 2
                Label {
                    id: _lableRD11
                    font.pixelSize: 22
                    font.italic: true
                    text: qsTr("par1")
                }

                TextField {
                    id: _lableRD11value
                    text: qsTr("20.01")
                }
                Label {
                    id: _lable1RD2
                    font.pixelSize: 22
                    font.italic: true
                    text: qsTr("par2")
                }

                TextField {
                    id: _lableRD12value
                    text: qsTr("20.02")
                }
                // 3
                Label {
                    id: _lableRD21
                    font.pixelSize: 22
                    font.italic: true
                    text: qsTr("par1")
                }

                TextField {
                    id: _lableRD21value
                    text: qsTr("20.01")
                }
                Label {
                    id: _lableRD22
                    font.pixelSize: 22
                    font.italic: true
                    text: qsTr("par2")
                }

                TextField {
                    id: _lableRD22value
                    text: qsTr("20.02")
                }
                // 4
                Label {
                    id: _lableRD31
                    font.pixelSize: 22
                    font.italic: true
                    text: qsTr("par1")
                }

                TextField {
                    id: _lableRD31value
                    text: qsTr("20.01")
                }
                Label {
                    id: _lableRD32
                    font.pixelSize: 22
                    font.italic: true
                    text: qsTr("par2")
                }

                TextField {
                    id: _lableRD32value
                    text: qsTr("20.02")
                }
            }

            Button {
                id: _okRDButton

                text: qsTr("发送")
                anchors.top: _ey.top
                anchors.topMargin: 10
                anchors.left: _ey.right
                anchors.leftMargin: 30

                height: _ey.height
                onClicked: {
                    console.log("begin to send")
                }
            }
        }
    }

    MouseArea {
        anchors.fill: parent
        onClicked: {
            loader.sourceComponent = _sub;
        }
    }

    TextField {
        id: _tetxField

        text: qsTr("_textField")
        anchors.centerIn: parent
    }
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值