12#if QT_CONFIG(textedit)
29#include <private/qitemeditorfactory_p.h>
32#include <private/qabstractitemdelegate_p.h>
33#include <private/qabstractitemmodel_p.h>
34#include <private/qtextengine_p.h>
35#include <private/qlayoutengine_p.h>
38#if QT_CONFIG(tableview)
263 index.multiData(modelRoleDataSpan);
268 option->font = qvariant_cast<QFont>(*value).resolve(
option->font);
274 option->displayAlignment = QtPrivate::legacyFlagValueFromModelData<Qt::Alignment>(*
value);
282 option->features |= QStyleOptionViewItem::HasCheckIndicator;
283 option->checkState = QtPrivate::legacyEnumValueFromModelData<Qt::CheckState>(*
value);
288 option->features |= QStyleOptionViewItem::HasDecoration;
289 switch (
value->userType()) {
290 case QMetaType::QIcon: {
292 if (
option->icon.isNull()) {
293 option->features &= ~QStyleOptionViewItem::HasDecoration;
310 case QMetaType::QColor: {
316 case QMetaType::QImage: {
319 option->decorationSize =
image.deviceIndependentSize().toSize();
322 case QMetaType::QPixmap: {
325 option->decorationSize =
pixmap.deviceIndependentSize().toSize();
335 option->features |= QStyleOptionViewItem::HasDisplay;
340 option->backgroundBrush = qvariant_cast<QBrush>(*
value);
343 option->styleObject =
nullptr;
396 return qvariant_cast<QSize>(
value);
413 const QStyleOptionViewItem &
option,
418 if (!
index.isValid())
435 QByteArray n = editor->metaObject()->userProperty().name();
440 editor->setProperty(
n,
v);
461 QByteArray n = editor->metaObject()->userProperty().name();
463 n =
d->editorFactory()->valuePropertyName(
474 const QStyleOptionViewItem &
option,
488 editor->setGeometry(geom);
551 return d->editorEventFilter(
object,
event);
559 const QStyleOptionViewItem &
option,
573 if (!
value.isValid())
583 QStyleOptionViewItem viewOpt(
option);
612#include "moc_qstyleditemdelegate.cpp"
The QAbstractItemDelegate class is used to display and edit data items from a model.
virtual Q_INVOKABLE bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
Sets the role data for the item at index to value.
Qt::ItemFlags flags(const QModelIndex &index) const override
\reimp
static QStyle * style()
Returns the application's style object.
\reentrant \inmodule QtGui
The QIcon class provides scalable icons in different modes and states.
Mode
This enum type describes the mode for which a pixmap is intended to be used.
State
This enum describes the state for which a pixmap is intended to be used.
The QItemEditorFactory class provides widgets for editing item data in views and delegates.
static const QItemEditorFactory * defaultFactory()
Returns the default item editor factory.
The QKeyEvent class describes a key event.
int key() const
Returns the code of the key that was pressed or released.
QObject * parent() const
Returns a pointer to the parent object.
The QPainter class performs low-level painting on widgets and other paint devices.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
\inmodule QtCore\reentrant
QPointF position() const
Returns the position of the point in this event, relative to the widget or item that received the eve...
Qt::MouseButton button() const
Returns the button that caused the event.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
QVariant data(const QModelIndex &item, int role=Qt::DisplayRole) const override
Returns the value for the specified item and role.
\macro QT_RESTRICTED_CAST_FROM_ASCII
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w=nullptr) const =0
Returns the size of the element described by the specified option and type, based on the provided con...
@ SH_ItemView_ShowDecorationSelected
virtual QRect subElementRect(SubElement subElement, const QStyleOption *option, const QWidget *widget=nullptr) const =0
Returns the sub-area for the given element as described in the provided style option.
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const =0
Draws the given element with the provided painter with the style options specified by option.
@ SE_ItemViewItemCheckIndicator
QItemEditorFactory * factory
static const QWidget * widget(const QStyleOptionViewItem &option)
QStyledItemDelegatePrivate()
std::array< QModelRoleData, 7 > modelRoleData
const QItemEditorFactory * editorFactory() const
The QStyledItemDelegate class provides display and editing facilities for data items from a model.
void setEditorData(QWidget *editor, const QModelIndex &index) const override
Sets the data to be displayed and edited by the editor from the data model item specified by the mode...
virtual QString displayText(const QVariant &value, const QLocale &locale) const
This function returns the string that the delegate will use to display the Qt::DisplayRole of the mod...
QStyledItemDelegate(QObject *parent=nullptr)
Constructs an item delegate with the given parent.
~QStyledItemDelegate()
Destroys the item delegate.
void setItemEditorFactory(QItemEditorFactory *factory)
Sets the editor factory to be used by the item delegate to be the factory specified.
bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override
\reimp
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
Gets data from the editor widget and stores it in the specified model at the item index.
virtual void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const
Initialize option with the values using the index index.
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Updates the editor for the item specified by index according to the style option given.
QItemEditorFactory * itemEditorFactory() const
Returns the editor factory used by the item delegate.
bool eventFilter(QObject *object, QEvent *event) override
Returns true if the given editor is a valid QWidget and the given event is handled; otherwise returns...
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Returns the widget used to edit the item specified by index for editing.
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
Returns the size needed by the delegate to display the item specified by index, taking into account t...
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Renders the delegate using the given painter and style option for the item specified by index.
void * data()
Returns a pointer to the contained object as a generic void* that can be written to.
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
constexpr const T & qMin(const T &a, const T &b)
GLsizei const GLfloat * v
[13]
QSqlQueryModel * model
[16]
QItemEditorFactory * factory