Should Q_PROPERTY always be CONSTANT or NOTIFY?
Hi,
I have a Q_PROPERTY like so:
Code:
Q_PROPERTY(QString name READ name WRITE setName
)
clazy warns that
Quote:
a non-CONSTANT Q_PROPERTY is missing a NOTIFY signal.
https://github.com/KDE/clazy/blob/1....hout-notify.md
Why is that? In my case it cant be CONSTANT because it has a WRITE setter. But it cant be NOTIFY either because there is no signal fired when it is set.
I am rarely using Q_PROPERTY, so my best guess is it's not the right tool for the case I am describing. If so, why not?
Qt doc (https://doc.qt.io/qt-6/properties.html) also has some examples that look just like mine.
Re: Should Q_PROPERTY always be CONSTANT or NOTIFY?
According the qt doc you posted the notify signal is optional so you're good like that, that should be just a warning. If you want to ger rid of that warning, just add a notify signal, even if you dont need it
Code:
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged
)
// you have to declare the notify signal
signals:
void nameChanged(int newName);