Formatting and coding standards for ProjT Launcher.
All C++ code must be formatted with clang-format before committing.
clang-format -i path/to/file.cppCI will reject unformatted code.
| Feature | Usage |
|---|---|
auto |
Only when type is obvious |
nullptr |
Always (never NULL or 0) |
override |
Required on all overrides |
const |
Required for non-mutating methods |
Smart Pointers:
// Good
auto obj = std::make_unique<MyClass>();
// Bad - raw pointer ownership
MyClass* obj = new MyClass();Qt Parent Ownership:
// Good - Qt manages lifetime
new QButton(this);- Avoid exceptions
- Use
std::optionalfor missing values - Use
std::expectedfor operations that can fail
// Good - explicit capture
connect(btn, &QPushButton::clicked, this, [this, id]() {
handleClick(id);
});
// Bad - default capture
connect(btn, &QPushButton::clicked, [=]() { ... });| Type | Format | Example |
|---|---|---|
| Class | PascalCase | MainWindow |
| Private member | m_ + camelCase |
m_currentTheme |
| Static member | s_ + camelCase |
s_instance |
| Public member | camelCase | dateOfBirth |
| Constant | SCREAMING_SNAKE | MAX_VALUE |
| Function | camelCase | getCurrentTheme() |
| Enum values | PascalCase | State::Running |
SCREAMING_SNAKE scope: Use for constexpr constants, #define macros, and legacy enum values only. Prefer enum class with PascalCase values for new code.
#pragma once- Corresponding header
- C++ standard library
- Qt headers
- Third-party headers
- Project headers
#include "MyClass.h"
#include <memory>
#include <string>
#include <QObject>
#include <QString>
#include "OtherClass.h"Note: clang-format automatically reorders includes. Always accept its output.
Prefer forward declarations over includes when possible:
// Good
class OtherClass;
// Avoid
#include "OtherClass.h"Qt warning: Forward declarations do not work for QObject-derived classes that use Q_OBJECT. These must be fully included.
/// @brief Short description.
///
/// Detailed description if needed.
/// @param input Description of parameter.
/// @return Description of return value.
bool doSomething(const QString& input);// Why this approach was chosen
// NOT what the code does// TODO(username): Description of what needs to be done
// FIXME(username): Description of broken behavior that needs fixing- TODO: Planned improvement or missing feature
- FIXME: Known bug or broken behavior requiring attention
- Username is required for traceability
- Compatible with IDE TODO/FIXME highlighting tools
- Use Qt Designer for layout
- Never edit generated
ui_*.hfiles - Set meaningful
objectNamevalues
- Keep UI logic minimal
- Delegate to core services
- Use signals/slots for communication
These templates apply only to new Project Tick–owned files. Do not modify license headers in upstream forked code.
// SPDX-License-Identifier: GPL-3.0-only
// SPDX-FileCopyrightText: 2026 Project Tick
#pragma once
#include <QObject>
class MyClass : public QObject {
Q_OBJECT
public:
explicit MyClass(QObject* parent = nullptr);
~MyClass() override;
signals:
void somethingHappened();
private:
QString m_data;
};// SPDX-License-Identifier: GPL-3.0-only
// SPDX-FileCopyrightText: 2026 Project Tick
#include "MyClass.h"
MyClass::MyClass(QObject* parent)
: QObject(parent)
{
}
MyClass::~MyClass() = default;