summaryrefslogtreecommitdiffstats
path: root/src/corelib/doc/snippets/code/qlogging/qlogging.cpp
blob: e61eb70df30f89178966c0549c3f05109fa9cc81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses

#include <QtGui>
#include <QtDebug>
#include <QQmlComponent>

//! [1]
    void statusChanged(QQmlComponent::Status status) {
        if (status == QQmlComponent::Error) {
            for (const QQmlError &error: std::as_const(component->errors())) {
                const QByteArray file = error.url().toEncoded();
                QMessageLogger(file.constData(), error.line(), 0).debug() << error.description();
            }
        }
    }
//! [1]

//! [2]
    const QLoggingCategory &category();
//! [2]