Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqmlloggingcategorybase_p.h
Go to the documentation of this file.
1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQMLLOGGINGCATEGORYBASE_P_H
5#define QQMLLOGGINGCATEGORYBASE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQml/qqml.h>
19
20#include <QtCore/qobject.h>
21#include <QtCore/qloggingcategory.h>
22
23#include <memory>
24
26
28{
29 Q_OBJECT
30 QML_ANONYMOUS
31
32public:
33 QQmlLoggingCategoryBase(QObject *parent = nullptr) : QObject(parent) {}
34
35 const QLoggingCategory *category() {
36 forceCompletion();
37 return m_category.get();
38 }
39 void setCategory(const char *name, QtMsgType type)
40 {
41 m_category = std::make_unique<QLoggingCategory>(name, type);
42 }
43
44 virtual void forceCompletion() = 0;
45
46private:
47 std::unique_ptr<QLoggingCategory> m_category;
48};
49
50QT_END_NAMESPACE
51
52#endif // QQMLLOGGINGCATEGORYBASE_P_H