[SOLVED] Q_PROPERTY only working for boolean setters/getters
I'm attempting to add a Q_PROPERTY for time.
Q_PROPERTY(int64_t time READ getTime WRITE setTIME)
void setTime(const int64_t x);
int64_t getTime() const;
I can't get this to show up in QtDesigner for my custom widget.
In fact, I can't get this to work for any data type besides boolean.
Q_PROPERTY(bool value READ getValue WRITE setValue)
void setValue(const bool x);
bool getValue() const;
This works just fine.
Am I missing something? I've read over the documentation and have not been able to come up with a solution.
When using special types, you must make it known to Qt using Q_DECLARE_METATYPE and qRegisterMetaType. It's explained with more details in the "Property System" chapter.
Hope it helps
Hey, thanks for the help. That appears to be working somewhat.
Next question, what about enums? Can I set up a Q_PROPERTY for enums? Documentation says I can only register types with a public ctor, copy-ctor, and a dtor.
Also, just in case, I got my time value to appear in the property sheet but it seems I can't change the value. No matter what I attempt to set the value to, it defaults back to a very large garbage number.
You have an example of that shown in the "Property System" chapter in the part "A simple example"
Are you sure you are setting and returning the value correctly from your class ?