Skip to content

Coding Style

Felix Turowsky edited this page Dec 12, 2020 · 6 revisions

Coding Style

This page is under construction. Check here for the discussion.

See https://wiki.qt.io/Qt_Coding_Style for general code style guidelines.

item convention example
Directory All lowercase with - for word separator if necessary. src/subdirectory/directory-of-doom/
File All lowercase, follow Qts conventions. src/subdirectory/directory-of-doom/adatabase.h
Class PascalCase, follow Qt convention but change Q to A class ADataBase
Methods camelCase methodOfClass
Free Function camelCase with an extra a aConquerTheWorld()
Static Function Without a and snake_case to emphasise limited scope void utility_function_one()
Important variable camelCase importantVariable
Limited scope variables snake_case temporary_variable
constants All capital snake_case const auto IMPORTANT_CONSTANT = ASecretOfUniverse(42);
Type Alias follow Qt Convention using NewType = QMap<QString, int>

example

const auto IMPORTANT_CONSTANT = ASecretOfUniverse(42);

APilotEntry(int throwaway_variable)
    : importantMemberVariable(throwaway_variable)
{}
- AFooBar           - an important custom class.
- FooBar            - alias of important type.
- aFooBar()         - an important free function
- foo_bar()         - a static "utility" function
- niceVariable      - an important variable
- nice_variable     - a "consumable", limited scope variable.
Clone this wiki locally