I don't see why that's an issue. If you're in A, call it "component" if using it in B, call it "toto". The lexical scoping rules are clear, I don't want to work against them, I want to use them. Somewhere there is a registration of the special-property-id value of "toto" as a string to the object reference itself. I just want access to that, so I won't need to do extra, duplicate work.
Sent: Wednesday, October 03, 2018 at 12:10 PM
From: "Jérôme Godbout" <godbo...@amotus.ca>
To: "Jason H" <jh...@gmx.com>
Cc: "Qt Interest" <interest@qt-project.org>
Subject: Re: [Interest] QML id as string?
From: "Jérôme Godbout" <godbo...@amotus.ca>
To: "Jason H" <jh...@gmx.com>
Cc: "Qt Interest" <interest@qt-project.org>
Subject: Re: [Interest] QML id as string?
Take care, id are special property and they can be multiple based on the context
// A.qml
Item
{
id: component
}
// B.qml
Item
{
A
{
id: toto
}
}
What would be the id to be used for the A object with both id component and toto? This is why you probably want to give it a UUID for the objectname or print the whole hierarchy of parent to discover which one it is. The objectname also make it easy to find an object with the property. But setting a property with the id literal is a bad idea.
On Wed, 3 Oct 2018 at 11:52, Jason H <jh...@gmx.com> wrote:
I keep running into the fact that I want to be able to use QML item ids as strings. However no such child exists. I realize we can use the objectName property, but them I'm maintaining an objectName, which is no worse or better than me maintaining it myself. It would be a big help f I could set up a binding:
objectName: id
or
objectName: ""+id
Instead I have to maintain a name to object mapping as a property, which shouldn't be needed.
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
|
|
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest