是“var"吗?和“变体"一样的东西? [英] Are "var" and "variant" the same thing?

查看:26
本文介绍了是“var"吗?和“变体"一样的东西?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我了解,要在 QML 中将属性设为数组,您必须将其指定为 variantvar 类型:

From what I understand, to make a property an array in QML you must specify it as the type variant or var:

属性变量 myArray:[]

这似乎与以下内容完全相同:

And this appears to be exactly the same as:

属性变体 myArray:[]

这是真的吗?

推荐答案

根据Qt 5.0 变体文档:

变体类型是通用属性类型.它已过时,仅用于支持旧应用程序;新应用程序应该使用 var 类型属性.p>

The variant type is a generic property type. It is obsolete and exists only to support old applications; new applications should use var type properties instead.

所以是的,它是一样的,但你应该始终坚持使用 var(除非你有一个还不支持的早期版本).

So yes, it is the same, but you should always stick to var (unless you got an earlier version which does not support that yet).

这篇关于是“var"吗?和“变体"一样的东西?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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