Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qitemeditorfactory.h
Go to the documentation of this file.
1// Copyright (C) 2016 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 QITEMEDITORFACTORY_H
5#define QITEMEDITORFACTORY_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtCore/qmetaobject.h>
9#include <QtCore/qbytearray.h>
10#include <QtCore/qhash.h>
11#include <QtCore/qvariant.h>
12
14
16
17class QWidget;
18
19class Q_WIDGETS_EXPORT QItemEditorCreatorBase
20{
21public:
23
24 virtual QWidget *createWidget(QWidget *parent) const = 0;
25 virtual QByteArray valuePropertyName() const = 0;
26};
27
28template <class T>
30{
31public:
32 inline explicit QItemEditorCreator(const QByteArray &valuePropertyName);
33 inline QWidget *createWidget(QWidget *parent) const override { return new T(parent); }
34 inline QByteArray valuePropertyName() const override { return propertyName; }
35
36private:
37 QByteArray propertyName;
38};
39
40template <class T>
42{
43public:
45 : propertyName(T::staticMetaObject.userProperty().name())
46 {}
47 inline QWidget *createWidget(QWidget *parent) const override { return new T(parent); }
48 inline QByteArray valuePropertyName() const override { return propertyName; }
49
50private:
51 QByteArray propertyName;
52};
53
54
55template <class T>
56Q_INLINE_TEMPLATE QItemEditorCreator<T>::QItemEditorCreator(const QByteArray &avaluePropertyName)
57 : propertyName(avaluePropertyName) {}
58
59class Q_WIDGETS_EXPORT QItemEditorFactory
60{
61public:
63 virtual ~QItemEditorFactory();
64
65 virtual QWidget *createEditor(int userType, QWidget *parent) const;
66 virtual QByteArray valuePropertyName(int userType) const;
67
69
70 static const QItemEditorFactory *defaultFactory();
71 static void setDefaultFactory(QItemEditorFactory *factory);
72
73private:
74 QHash<int, QItemEditorCreatorBase *> creatorMap;
75};
76
78
79#endif // QITEMEDITORFACTORY_H
\inmodule QtCore
Definition qbytearray.h:57
The QItemEditorCreatorBase class provides an abstract base class that must be subclassed when impleme...
virtual QByteArray valuePropertyName() const =0
Returns the name of the property used to get and set values in the creator's editor widgets.
virtual QWidget * createWidget(QWidget *parent) const =0
Returns an editor widget with the given parent.
The QItemEditorCreator class makes it possible to create item editor creator bases without subclassin...
QItemEditorCreator(const QByteArray &valuePropertyName)
Constructs an editor creator object using valuePropertyName as the name of the property to be used fo...
QWidget * createWidget(QWidget *parent) const override
\reimp
QByteArray valuePropertyName() const override
\reimp
The QItemEditorFactory class provides widgets for editing item data in views and delegates.
QItemEditorFactory()
Constructs a new item editor factory.
The QStandardItemEditorCreator class provides the possibility to register widgets without having to s...
QStandardItemEditorCreator()
Constructs an editor creator object.
QByteArray valuePropertyName() const override
\reimp
QWidget * createWidget(QWidget *parent) const override
\reimp
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
Combined button and popup list for selecting options.
GLuint name
#define QT_REQUIRE_CONFIG(feature)
QItemEditorCreatorBase * creator
editorFactory registerEditor(QMetaType::QDateTime, creator)
QItemEditorFactory * factory