[Qt-creator] A really minor observation about QML & properties

Damian Ivanov damianatorrpm at gmail.com
Mon Sep 9 21:29:27 CEST 2019


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.
https://doc.qt.io/qt-5/properties.html

Regards,
Damian

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 mailing list