Contributing to the VoltAir Project
|
The most complete style guide to QML is the source code itself. Try to make any additions look as close as possible to the existing code.
The overall philosophy of our QML style is as follows:
id
and objectName
)QtObject
Additionally, there are also several ordering rules for guidance.
In our adopted convention, a line break should minimally be inserted after each "region".
Additionally, intra-region line breaks can be added (e.g. logical grouping of property initializations or separating JavaScript functions).
Our recommended "Region" ordering after declaration is as follows:
id
and objectName
)anchor
properties)width
and height
)z
)visible
) / Enabled state (i.e. enabled
)state
and states
transitions
(animation component declarations need not recursively follow region line breaks)Keys
slots)Object name, if needed, should always be the string literal of the id name.
QtObject
whose id
property is "d"We provide the following code sample which demonstrates the our conventions:
Component { id: foo objectName: "foo" property real customProp1: 14.0 property bool customProp2: false property alias aliasedProperty: subComponent1.aliasedProperty signal mySignal() function customJavaScriptFunc() { ... } anchors.horizontalCenter: parent.center width: 0.1 * parent.width height: 2 * width z: 1 visible: false opacity: 0.0 enabled: false bar: 0.6 baz: "hello,world" state: "STARTING_STATE" states: [ State { name: "STARTING_STATE" }, State { name: "ENDING_STATE" } ] transitions: [ Transition { to: "STARTING_STATE" ... }, Transition { to: "ENDING_STATE" ... } ] SubComponent1 { id: subComponent1 ... } SubComponent2 { ... } onMyCustomSlot: { ... } // "Static" slots Keys.onPressed: { ... } // Encapsulation of private properties. QtObject { id: private property int temporaryVariable: 678 } }