Repeater and itemAt issue
-
@Stefan-Monov76 That is because there is no guarantee that those component have been instantiated even by then.
-
@p3c0 :
Your own code relies onrectRepeater
having instantiated its items by the timeonCompleted
fires. My code relies on exactly the same. So there shouldn't be any difference, should there? -
@Stefan-Monov76 My code atleast guarantees that the 2nd Repeater doesnot start instantiating items before 1st repeater have finished instantiating them because 2nd Repeater's Items depends on 1st Repeater's Item.
-
@p3c0 :
If I'm not mistaken,Component.onCompleted
fires only when the entire top-level component (in this case theWindow
) has finished loading. Even when I've put theComponent.onCompleted
handler inside my Text item. So my code only accesses the first Repeater's items when the Window has loaded. And if the Window has loaded, then the first Repeater has already instantiated its items. No? -
@Stefan-Monov76 No. Each component has this attached property.
-
@p3c0 :
Thanks again for the continued replies. I don't intend to argue or prove myself right, just to clear up the situation for myself, mind you! :)
The docs say a component is one of two things:- a type defined by the top-level element of a QML file (one type per file) - in my case, I have defined exactly one such component, and it "derives" from
Window
- an object defined inline by instantiating the
Component
type, that you can later instantiate via aLoader
object. This scenario is irrelevant here.
So my
Text
objects are not components, they are merely objects, and since they are not components, they don't have aComponent.onCompleted
signal, they use theWindow
'sComponent.onCompleted
signal.It's important to me to be strict when using the term "Component", it has a very specific meaning in QML.
- a type defined by the top-level element of a QML file (one type per file) - in my case, I have defined exactly one such component, and it "derives" from
-
@Stefan-Monov76 That's fine :)
component in this case I was referring to QML types that are inheritsItem
. I generally prefer to say QML components when referring to these types. Sorry for not being clear.
So basically any QML type that inheritsItem
has theComponent.onCompleted
signal. For eg.Text
,Rectangle
,Row
...
Here is the complete list:
http://doc.qt.io/qt-5/qml-qtquick-item.html
Look for the row named by "Inherited By". -
@p3c0 :
Hmm, the docs for theItem
type that you link to don't mention having the onCompleted signal. -
@Stefan-Monov76 It is an attached signal. It is mentioned here.
An attached signal handler is referred to in the same way. For example, the Component.onCompleted attached signal handler is commonly used to execute some JavaScript code when a component's creation process has been completed.
-
@p3c0 :
Ok, thanks.