I use QBindable a lot in C++ classes that expose properties to QML.
My typical property implementation looks as follows:

Q_PROPERTY(qreal x BINDABLE getBindableX READ default FINAL)
//...
QProperty<qreal> m_X;
//...
CPropertyClass::getBindableX() const
{
    return &m_X;
}

I got the idea to use "&m_X" to get the QBindable for a property from the 
example in QObjectBindableProperty. And initially, I also used 
QObjectBindableProperty via Q_OBJECT_BINDABLE_PROPERTY macro.
But once QML natively supported BINDABLE properties, I no longer saw any 
advantage, and using QProperty produces less boilerplate.

So the usage of "&m_X" to get QBindable is documented for 
QObjectBindableProperty, but only in the example, not in the docs specifically. 
It feels a bit dirty to create a derived class via promotion from a base class.
And for QProperty, "&m_X" is not documented even in an example.

So the question is: Is it safe to use? Have I misunderstood something by 
choosing QProperty over Q_OBJECT_BINDABLE_PROPERTY?

Robert Schimkowitsch
________________________________

This message and any attachments are solely for the use of the intended 
recipients. They may contain privileged and/or confidential information or 
other information protected from disclosure. If you are not an intended 
recipient, you are hereby notified that you received this email in error and 
that any review, dissemination, distribution or copying of this email and any 
attachment is strictly prohibited. If you have received this email in error, 
please contact the sender and delete the message and any attachment from your 
system.

ANDRITZ HYDRO GmbH


Rechtsform/ Legal form: Gesellschaft mit beschränkter Haftung / Corporation

Firmensitz/ Registered seat: Wien

Firmenbuchgericht/ Court of registry: Handelsgericht Wien

Firmenbuchnummer/ Company registration: FN 61833 g

DVR: 0605077

UID-Nr.: ATU14756806


Thank You
________________________________
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to