Qt custom property Q_PROPERTY does not display float type

Recently, I am learning to write custom controls, which use Q_PROPERTY to set custom properties.
You can know from the information that the type supported by Q_PROPERTY can be any type supported by QVariant, or our custom type, and others are optional. After setting, we will see our properties in the property editing table when calling the custom control. As shown in the figure below
insert image description here
, however, in use today, I found that two custom attributes min and max were missing, so I looked for the reason.

Later, it was found that there are only two types of numbers displayed in the attribute table: int and double (such as spin box and double spin box), and the attributes of type float cannot be displayed, so min and max are not displayed.

Then, after changing Q_PROPERTY and function implementation to double, it can be displayed normally, as shown in the figure below.
insert image description here
Therefore, Q_PROPERTY may support many types, but may not be able to display multiple types.

Guess you like

Origin blog.csdn.net/weixin_44650358/article/details/127494560