Qt6/Example-Guideline
Jump to navigation
Jump to search
When creating or updating Qt examples, developer should consider the best practises and guidelines listed in this document.
Evaluate if the example is meaningful or should it be removed/merged
MANDATORY
- Check if there are similar examples for the same topic and consider if both are really needed or should the other one be merged with the other.
- Check also documentation on the topic and if that includes inline code snippet that would be adequate instead of complete example.
No C++ or qml warnings
MANDATORY
- Example's C++ code should be by minimum compiled with the same compiler warning flags as Qt.
- Use qmllint for qml code: https://doc-snapshots.qt.io/qt6-dev/qtquick-tool-qmllint.html
- Enable compiler warnings and check if the reported issues are fixable with meaningful effort.
RECOMMENDED Consider also the compilation with the more strict warning flags and fix the found issues.
GCC
- Use -Wall and consider -Wextra parameter: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
Clang
- Use -Weverything compiler parameter: https://clang.llvm.org/docs/UsersManual.html#diagnostics-enable-everything
Visual Studio
- Use /Wall compiler parameter: https://docs.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level