-
Notifications
You must be signed in to change notification settings - Fork 6
Naming and Coding Conventions
Use meaningful names.
Don't use abbreviations.
If your class can be contained in a list also introduce a list type. Don't forget the Q_DECLARE_TYPENAME.
Only inherit from QObject if really necessary.
Only lower case, underscores only if really necessary.
A file should be called like the biggest class / function it contains.
CamelCase, no prefix or underscores.
First letter must be in upper case.
Should be called like the file it is in.
Every class must have a constructor and destructor.
Base classes which do not derive from other classes must have a virtual destructor.
CamelCase, no underscores.
First letter must be in lower case.
All but pointers and primitive types have to be passed as const reference.
No "get"-prefix for getter functions, they must be called like the variable it gets.
A getter must be const.
"set"-prefix for setter functions, must only contain one parameter. Must be named like the variable it sets.
Set functions have to compare the new value with the old value, only if they differ the new is set (and only emit a signal if the value changed!).
All classes which are exported have to use a private implementation.
All other member variables must be prefixed "m_" and named like local variables.
Do not use!
CamelCase, first letter must be in lowercase.
Give a variable only to scripting if it is really necessary.
All variables accessible by the scripting must have a getter, setter and a signal for changes. They must be marked by Q_PROPERTY.
Functions called by the scripting have to be SLOTS or Q_INVOKABLE.
Don't forget to use qmlRegisterMetatype() for all classes used in the scripting.