summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/accessibilitypluginsnippet.cpp
blob: ad6d4377aa70e59b56a60d1d5a4bdf403e8f3741 (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
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#include <QtGui>

class SliderPlugin : public QAccessiblePlugin
{
//! [2]
    Q_OBJECT
    Q_PLUGIN_METADATA(IID "org.qt-project.Qt.Examples.Accessibility.SliderPlugin" FILE "slider.json")
//! [2]

public:
    SliderPlugin() {}

    QStringList keys() const;
    QAccessibleInterface *create(const QString &classname, QObject *object);
};

//! [0]
QStringList SliderPlugin::keys() const
{
    return QStringList() << QLatin1String("QSlider");
}
//! [0]

//! [1]
QAccessibleInterface *SliderPlugin::create(const QString &classname, QObject *object)
{
    QAccessibleInterface *interface = 0;

    if (classname == QLatin1String("QSlider") && object && object->isWidgetType())
        interface = new QAccessibleSlider(static_cast<QWidget *>(object));

    return interface;
}
//! [1]