QML ScrollView默认滚动条的使用

QML ScrollView默认滚动条的使用

问题:
在这里插入图片描述
有的时候某一窗口限制在一定的大小导致内容显示不全并且不会自动出现滚动条,查了资料发现了Scrollview方法,将GroupBox放入Scrollview中,clip属性删除Scrollview以外的部分,完成。
全部代码:

import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.14
import QtQuick.Layouts 1.2

Window {
    width: 300
    height: 200
    visible: true
    title: qsTr("NameList")
    ScrollView{
        width:300
        height:200
        clip:true
        GroupBox{
            GridLayout{
                id:idlist
                columns: 4
                rows: 4
                Text {
                    text:"姓名"
                }
                TextField{
                    id:name1
                    text:nametext1
                    onEditingFinished: {
                        nametext1 = text
                    }
                }
                Text {
                    text:"班级"
                }
                TextField{
                    id:class1
                    text:classtext1
                    onEditingFinished: {
                        classtext1 = text
                    }
                }
                Text {
                    text:"出生年月"
                }
                TextField{
                    id:birth1
                    text:birthtext1
                    onEditingFinished: {
                        birthtext1 = text
                    }
                }
                Text {
                    text:"身高"
                }
                TextField{
                    id:stature1
                    text:staturetext1
                    onEditingFinished: {
                        staturetext1 = text
                    }
                }
                Text {
                    text:"体重"
                }
                TextField{
                    id:weight1
                    text:weighttext1
                    onEditingFinished: {
                        weighttext1 = text
                    }
                }
                Text {
                    text:"语文"
                }
                TextField{
                    id:chinese1
                    text:chinesetext1
                    onEditingFinished: {
                        chinesetext1 = text
                    }
                }
                Text {
                    text:"数学"
                }
                TextField{
                    id:math1
                    text:mathtext1
                    onEditingFinished: {
                        mathtext1 = text
                    }
                }
                Text {
                    text:"英语"
                }
                TextField{
                    id:english1
                    text:englishtext1
                    onEditingFinished: {
                        englishtext1 = text
                    }
                }
                Text {
                    text:"物理"
                }
                TextField{
                    id:physical1
                    text:physicaltext1
                    onEditingFinished: {
                        physicaltext1 = text
                    }
                }
            }
        }
    }
}

在这里插入图片描述

在这里插入图片描述

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值