Naming conventions in QML
-
Hi,
Is there any list of naming conventions in QML ? QML's coding conventions page at http://doc.qt.nokia.com/latest/qml-coding-conventions.html does not say anything about naming conventions.
-
Because it is really similar to Qt naming conventions maybe?
-
Actually I find it a little different. So let's say I create my own component which contains other elements:
@
MyRectangle {
id: ????
width: 80; height: 80Item { //item1 } Item { //item2 }
}
@
Now what should be the default id for MyRectangle ? Should it be "container" or "myRectangle". container is the one used by QML examples at many places for elements which contain other elements. -
I'm not sure it should be covered with naming convention.
-
Since all the names in QML are kind of "global"; the only way to avoid naming conflicts is by following strict naming conventions. It's possible to declare two different elements with same name. Which name would be visible if I use them at third place ? Does it only depend upon order of declaration of elements ?
-
Hi,
If you create a MyRectangle.qml as follows:
@
//MyRectangle.qml
Rectangle {
id: ????
width: 80; height: 80Item { id: item1 } Item { id: item2 }
}
@The id you assign to the top level Rectangle will not be visible "outside" the component. For example, in the following case:
@
//main.qml
Item {
MyRectangle {}
}
@the id assigned to the Rectangle in MyRectangle.qml will not be visible in main.qml. Does this answer your question about naming conflicts/visibility, or was there a different case you were concerned with?
Regards,
Michael -
Hi,
Can you provide me any page which explains how names are managed and shadowed in QML ?
-
Hi,
The scope documentation can be found at http://doc.qt.nokia.com/4.7-snapshot/qdeclarativescope.html -- I think this should have the information you are after.
Regards,
Michael