- Qt 6.8
- Qt QML Compiler
- QML Static Analysis 3 - Fixit Hints
- Qt 6.8.3 Reference Documentation

QML Static Analysis 2 - Custom Pass

# QML Static Analysis 3 - Fixit Hints

In this chapter we learn how to improve our custom warnings by amending them with fixit hints.

So far, we only created warning messages. However, sometimes we also want to add a tip for the user how to fix the code. For that, we can pass an instance of `FixSuggestion` to emitWarning. A fix suggestion always consists of a description of what should be fixed, and the location where it should apply. It can also feature a replacement text. By default, the replacement text is only shown in the diagnostic message. By calling `setAutoApplicable(true)` on the `FixSuggestion`, the user can however apply the fix automatically via qmllint or the QML language server. It is important to only mark the suggestion as auto-applicable if the resulting code is valid.