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
qabstractitemdelegate.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 QABSTRACTITEMDELEGATE_H
5#define QABSTRACTITEMDELEGATE_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtCore/qobject.h>
9#include <QtWidgets/qstyleoption.h>
10
12
14
15class QPainter;
16class QModelIndex;
19class QHelpEvent;
21
22class Q_WIDGETS_EXPORT QAbstractItemDelegate : public QObject
23{
25
26public:
27
35
36 explicit QAbstractItemDelegate(QObject *parent = nullptr);
37 virtual ~QAbstractItemDelegate();
38
39 // painting
40 virtual void paint(QPainter *painter,
41 const QStyleOptionViewItem &option,
42 const QModelIndex &index) const = 0;
43
44 virtual QSize sizeHint(const QStyleOptionViewItem &option,
45 const QModelIndex &index) const = 0;
46
47 // editing
48 virtual QWidget *createEditor(QWidget *parent,
49 const QStyleOptionViewItem &option,
50 const QModelIndex &index) const;
51
52 virtual void destroyEditor(QWidget *editor, const QModelIndex &index) const;
53
54 virtual void setEditorData(QWidget *editor, const QModelIndex &index) const;
55
56 virtual void setModelData(QWidget *editor,
58 const QModelIndex &index) const;
59
60 virtual void updateEditorGeometry(QWidget *editor,
61 const QStyleOptionViewItem &option,
62 const QModelIndex &index) const;
63
64 // for non-widget editors
65 virtual bool editorEvent(QEvent *event,
67 const QStyleOptionViewItem &option,
68 const QModelIndex &index);
69
70 virtual bool helpEvent(QHelpEvent *event,
72 const QStyleOptionViewItem &option,
73 const QModelIndex &index);
74
75 virtual QList<int> paintingRoles() const;
76
78 void commitData(QWidget *editor);
81
82protected:
83 QAbstractItemDelegate(QObjectPrivate &, QObject *parent = nullptr);
84private:
85 Q_DECLARE_PRIVATE(QAbstractItemDelegate)
86 Q_DISABLE_COPY(QAbstractItemDelegate)
87 Q_PRIVATE_SLOT(d_func(), void _q_commitDataAndCloseEditor(QWidget*))
88};
89
91
92#endif // QABSTRACTITEMDELEGATE_H
The QAbstractItemDelegate class is used to display and edit data items from a model.
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const =0
This pure abstract function must be reimplemented if you want to provide custom rendering.
void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint=NoHint)
This signal is emitted when the user has finished editing an item using the specified editor.
void commitData(QWidget *editor)
This signal must be emitted when the editor widget has completed editing the data,...
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const =0
This pure abstract function must be reimplemented if you want to provide custom rendering.
EndEditHint
This enum describes the different hints that the delegate can give to the model and view components t...
void sizeHintChanged(const QModelIndex &)
The QAbstractItemView class provides the basic functionality for item view classes.
\inmodule QtCore
Definition qcoreevent.h:45
The QHelpEvent class provides an event that is used to request helpful information about a particular...
Definition qevent.h:788
\inmodule QtCore
\inmodule QtCore
Definition qobject.h:103
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
\inmodule QtCore
Definition qsize.h:25
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 index
[2]
struct _cl_event * event
GLuint GLenum option
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
#define QT_REQUIRE_CONFIG(feature)
#define Q_OBJECT
#define Q_PRIVATE_SLOT(d, signature)
#define Q_SIGNALS
QSqlQueryModel * model
[16]
QPainter painter(this)
[7]
QQuickView * view
[0]