aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/doc/how-tos/how-to-cpp-gauge/tickmarklabelcontainer.h
blob: e940914eb3aa096231e9f8e1d44ddb3c52bbc905 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#ifndef TICKMARKLABELCONTAINER_H
#define TICKMARKLABELCONTAINER_H

#include <QFont>
#include <QQmlComponent>
#include <QQuickItem>

#include "tickmarkcontainer.h"

QT_BEGIN_NAMESPACE

class TickmarkLabelContainer : public TickmarkContainer
{
    Q_OBJECT
    Q_PROPERTY(QFont font READ font WRITE setFont RESET resetFont NOTIFY fontChanged REQUIRED FINAL)

    QML_ELEMENT

public:
    TickmarkLabelContainer(QQuickItem *parent = nullptr);
    virtual ~TickmarkLabelContainer() = default;

    QFont font() const;
    void setFont(const QFont &font);
    void resetFont();

Q_SIGNALS:
    void fontChanged();

protected:
    void updatePolish() override;

private:
    Q_DISABLE_COPY(TickmarkLabelContainer)

    void recreateDelegateItems() override;

    // Not used by us other than to detect when the labels
    // should be repositioned due to implicit size changes.
    // Assuming Label is used as the delegate, Control's font
    // propagation already ensures that the correct font is used.
    QFont mFont;
};

QT_END_NAMESPACE

#endif // TICKMARKLABELCONTAINER_H