[Qt-creator] A really minor observation about QML & properties
jhihn at gmx.com
Tue Sep 10 15:57:44 CEST 2019
I don't _think_ this is how Qt APIs work though? Maybe I missed something, Qt classically has not used getXXXX() as a getter, but still provide properties and getters of the same name? I had expected to be told something about how to change my declaration.
For example, QML Item instantiates QQuickItem. both have "clip".
Q_PROPERTY(bool clip READ clip WRITE setClip NOTIFY clipChanged)
This is a property of Item, and a public function (getter) of QQuickItem. I assume there is some magic that tells QtC to know that when completing clip, to not add "()" ?
Also, for the member version, the docs don't say it, but I assume there is a standard setter generated with the if-value-change notify guard?
> Sent: Monday, September 09, 2019 at 3:29 PM
> From: "Damian Ivanov" <damianatorrpm at gmail.com>
> To: "Jason H" <jhihn at gmx.com>
> Cc: qt-creator <qt-creator at qt-project.org>
> Subject: Re: [Qt-creator] A really minor observation about QML & properties
> Hi Jason,
> The READ function should have a different name like getName() the
> string before Read is what is exposed to QML.
> Also you could use MEMBER but READ and WRITE functions are more
> flexible in the end.
> On Mon, Sep 9, 2019 at 9:32 PM Jason H <jhihn at gmx.com> wrote:
> > When I make my own QML components in C, and I have a property and a slot named he same:
> > Q_PROPERTY(QString name READ name WRITE setName ...)
> > When I'm typing, QtCreator appends "()" when I tab-complete rather than just completing the name.
> > x.na[TAB] -> x.name()
> > vs x.na[TAB] -> x.name (and continue on as: `= "name"`
> > Usually when this is the case in QML, I want just to use it as a property not a function. I've not observed this with Qt's built-in classes. Does anyone know what I'm doing differently/wrong/could be doing better?
> > Creator 4.9.2
> > _______________________________________________
> > Qt-creator mailing list
> > Qt-creator at qt-project.org
> > https://lists.qt-project.org/listinfo/qt-creator
More information about the Qt-creator