En esta página

LoggingCategory QML Type

Define una categoría de registro en QML. Más...

Import Statement: import QtQml

Propiedades

Descripción detallada

Se puede pasar una categoría de registro a console.log() y funciones similares como primer argumento. Si se proporciona al registrador, se utilizará el nombre de LoggingCategory como categoría de registro. De lo contrario, se utilizará la categoría de registro predeterminada.

import QtQuick

Item {
    LoggingCategory {
        id: category
        name: "com.qt.category"
        defaultLogLevel: LoggingCategory.Warning
    }

    Component.onCompleted: {
        console.log(category, "log message");
        console.warn(category, "warning message");
    }
}

Por defecto, esto solo muestra « com.qt.category: warning message ». El « log message » se suprime debido a « defaultLogLevel ». No obstante, puedes configurar los niveles de registro para las categorías de registro de QML del mismo modo que lo haces para QLoggingCategory.

Nota: Dado que la creación de objetos consume muchos recursos, se recomienda colocar las definiciones necesarias de LoggingCategory en un singleton e importarlo cuando sea necesario.

Véase también QLoggingCategory.

Documentación de propiedades

defaultLogLevel : enumeration

Establece el nivel de registro predeterminado de la categoría de registro. De forma predeterminada, se crea con el nivel de registro « LoggingCategory.Debug».

Están disponibles los siguientes valores de enumeración:

Reflejan los valores de la enumeración QtMsgType.

Nota: Esta propiedad debe establecerse al declarar el ` LoggingCategory ` y no puede modificarse posteriormente.

Véase también QtMsgType.

name : string

Contiene el nombre de la categoría de registro.

Nota: Esta propiedad debe configurarse al declarar la clase ` LoggingCategory ` y no puede modificarse posteriormente.

Véase también QLoggingCategory::categoryName().

© 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.