QML:调整大小复选框 [英] QML: Resize CheckBox

查看:905
本文介绍了QML:调整大小复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有自己的代理人的ListView.

I have ListView with my own delegate.

import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0

ItemDelegate
{
    height: 40

    Row
    {
        spacing: 10
        anchors.verticalCenter: parent.verticalCenter

        CheckBox
        {

        }
    }
}

问题在于,尽管ItemDelegate的高度很高,复选框的大小也不会调整.

The problem is that check boxes does not resize despite ItemDelegate's height.

我得到这个高度为40:

I get this for height = 40:

我得到的高度为10:

我尝试过使用CheckBox的宽度和高度值-并没有帮助.

I've tried playing with CheckBox'es width and height values - did not help.

是否可以在不进行自定义的情况下将其缩小?

Is it possible to make it smaller at all, without customizing it?

推荐答案

从理论上讲,您可以增加指标的大小,但不会增加选中标记图像的大小:

You can, in theory, increase the size of the indicator, but it won't increase the size of the checkmark image:

CheckBox {
    text: "CheckBox"
    anchors.centerIn: parent
    checked: true

    indicator.width: 64
    indicator.height: 64
}

图像没有缩放的原因有两个.首先,如果将复选标记放大,则该复选标记将变得模糊.更重要的是,要保持最佳性能. Qt Quick Controls 2不像Qt Quick Controls 1那样相对于彼此计算所有大小,而是创建大量的绑定,而是基于Qt 5.6中引入的自动高DPI缩放系统,而不是Qt Quick Controls 2的可伸缩性.当使用比例因子N运行时,您将得到不同的@Nx图像.

There are a couple of reasons why the image is not scaled. First of all, the checkmark would be blurry if it was upscaled. And more importantly, to retain best possible performance. Instead of calculating all the sizes relative to each other and that way creating huge amounts of bindings like Qt Quick Controls 1 did, Qt Quick Controls 2 bases its scalability instead on the automatic high-DPI scaling system introduced in Qt 5.6. You get simply a different @Nx image when running with scale factor N.

这篇关于QML:调整大小复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆