Análisis estático QML 3 - Pistas Fixit

En este capítulo aprenderemos a mejorar nuestras advertencias personalizadas modificándolas con sugerencias de Fixit.

Hasta ahora, sólo hemos creado mensajes de advertencia. Sin embargo, a veces también queremos añadir un consejo para el usuario sobre cómo arreglar el código. Para ello, podemos pasar una instancia de FixSuggestion a emitWarning. Una sugerencia de arreglo siempre consiste en una descripción de lo que debería arreglarse, y el lugar donde debería aplicarse. También puede incluir un texto de sustitución. Por defecto, el texto de sustitución sólo se muestra en el mensaje de diagnóstico. No obstante, el usuario puede aplicar la corrección automáticamente a través de qmllint o del QML Language Server llamando a setAutoApplicable(true) en FixSuggestion. Es importante marcar la sugerencia como autoaplicable sólo si el código resultante es válido.

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.