Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qstyleditemdelegate.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 QSTYLEDITEMDELEGATE_H
5#define QSTYLEDITEMDELEGATE_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtWidgets/qabstractitemdelegate.h>
9#include <QtCore/qstring.h>
10#include <QtGui/qpixmap.h>
11#include <QtCore/qvariant.h>
12
14
16
19
20class Q_WIDGETS_EXPORT QStyledItemDelegate : public QAbstractItemDelegate
21{
23
24public:
25 explicit QStyledItemDelegate(QObject *parent = nullptr);
27
28 // painting
30 const QStyleOptionViewItem &option, const QModelIndex &index) const override;
31 QSize sizeHint(const QStyleOptionViewItem &option,
32 const QModelIndex &index) const override;
33
34 // editing
36 const QStyleOptionViewItem &option,
37 const QModelIndex &index) const override;
38
39 void setEditorData(QWidget *editor, const QModelIndex &index) const override;
40 void setModelData(QWidget *editor,
42 const QModelIndex &index) const override;
43
44 void updateEditorGeometry(QWidget *editor,
45 const QStyleOptionViewItem &option,
46 const QModelIndex &index) const override;
47
48 // editor factory
49 QItemEditorFactory *itemEditorFactory() const;
50 void setItemEditorFactory(QItemEditorFactory *factory);
51
52 virtual QString displayText(const QVariant &value, const QLocale &locale) const;
53
54protected:
55 virtual void initStyleOption(QStyleOptionViewItem *option,
56 const QModelIndex &index) const;
57
58 bool eventFilter(QObject *object, QEvent *event) override;
60 const QStyleOptionViewItem &option, const QModelIndex &index) override;
61
62private:
63 Q_DECLARE_PRIVATE(QStyledItemDelegate)
64 Q_DISABLE_COPY(QStyledItemDelegate)
65};
66
68
69#endif // QSTYLEDITEMDELEGATE_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.
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
Returns the editor to be used for editing the data item with the given index.
virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
Updates the geometry of the editor for the item with the given index, according to the rectangle spec...
virtual bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
When editing of an item starts, this function is called with the event that triggered the editing,...
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const
Sets the contents of the given editor to the data for the item at the given index.
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
Sets the data for the item at the given index in the model to the contents of the given editor.
\inmodule QtCore
Definition qcoreevent.h:45
The QItemEditorFactory class provides widgets for editing item data in views and delegates.
\inmodule QtCore
\inmodule QtCore
Definition qobject.h:90
virtual bool eventFilter(QObject *watched, QEvent *event)
Filters events if this object has been installed as an event filter for the watched object.
Definition qobject.cpp:1518
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
The QStyledItemDelegate class provides display and editing facilities for data items from a model.
\inmodule QtCore
Definition qvariant.h:64
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
QPainter paint
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLuint index
[2]
struct _cl_event * event
GLuint GLenum option
#define QT_REQUIRE_CONFIG(feature)
#define Q_OBJECT
QSqlQueryModel * model
[16]
QItemEditorFactory * factory
QPainter painter(this)
[7]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent