Q_PROPERTYs in preferences code
Sebastian Kügler
sebas at kde.org
Thu Dec 21 04:09:06 PST 2017
Hi Berthold,
On Saturday, December 16, 2017 1:26:16 PM CET Berthold Stoeger wrote:
> Short question: Are the numerous Q_PROPERTY macros in core/subsurface-qt/
> SettingsObjectWrapper.h needed for the mobile version? If I remove them, the
> desktop version compiles and works just fine.
>
> Somehow this all seems redundant: Each property has a WRITE method and a
> NOTIFY signal, but the signal is raised in the WRITE method anyway..? Does
> this mean that the signals are raised twice on mobile?
The signal is not emitted automatically, for a QObject to properly work, one
has to define the Q_PROPERTY with READ, WRITE (optional) and NOTIFY (optionel)
methods. Qt's moc will then generate the boilerplate code, but the
implementation still needs to send / emit the signal.
For C++, this may not be needed in some cases, but QtQuick code (so the mobile
version) won't see any changes to the properties when the NOTIFY bit is
removed. You're not getting compile-time errors from that, so if you tweak
something there, be extremely careful.
Cheers,
--
sebas
http://www.kde.org | http://vizZzion.org
More information about the subsurface
mailing list