I'm working on a custom widget and wanted to make some float type properties. Unfortunately it doesn't seem that Qt Creator is a fan of those float type properties and isn't showing them in the property editor. All of my other properties work fine (int, bool, QString). Here's an example of how I declare the properties.
In the header file:
Q_PROPERTY( float Value
READ getValue
WRITE setValue
RESET resetValue )
float Value;
// ...
float getValue();
void resetValue();
void setValue( float value );
And in the source file:
float MyWidget::getValue()
{
return Value;
}
void MyWidget::resetValue()
{
Value = 0;
}
void MyWidget::setValue( float value )
{
Value = value;
}
Is there something special that needs to be done before floats can be used for widget properties?
double
should work as for exampleQWidget::windowOpacity
is a double type and it is displayed in the property editor. I am not sure whyfloat
doesn't work, but usually when some properties don't display in the property editor it is because it doesn't know what editor to use.