dbselect
Loading...
Searching...
No Matches
ComboDelegate Class Reference

Item delegate that edits a cell using a QComboBox populated from Qt::UserRole. More...

#include <dbselectView.h>

Public Member Functions

 ComboDelegate (QObject *parent=nullptr)
 Construct the delegate.
 
QWidget * createEditor (QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
 Create a QComboBox editor for the given cell.
 
void setEditorData (QWidget *editor, const QModelIndex &index) const override
 Populate the editor from the model.
 
void setModelData (QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
 Write the selected editor value back to the model.
 
void updateEditorGeometry (QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override
 Position the editor within the cell rectangle.
 

Detailed Description

The model is expected to store a QStringList in Qt::UserRole for the edited index. The delegate uses that list to populate the combo box and writes the selected value back to Qt::EditRole.

Definition at line 300 of file dbselectView.h.

Constructor & Destructor Documentation

◆ ComboDelegate()

ComboDelegate::ComboDelegate ( QObject * parent = nullptr)
inlineexplicit
Parameters
parentOptional Qt parent object.

Definition at line 307 of file dbselectView.h.

Member Function Documentation

◆ createEditor()

QWidget * ComboDelegate::createEditor ( QWidget * parent,
const QStyleOptionViewItem & option,
const QModelIndex & index ) const
inlineoverride

The editor is created empty; content is populated in setEditorData().

Parameters
parentParent widget for the editor.
optionStyle options (unused).
indexModel index (unused).
Returns
Newly created editor widget.

Definition at line 319 of file dbselectView.h.

◆ setEditorData()

void ComboDelegate::setEditorData ( QWidget * editor,
const QModelIndex & index ) const
inlineoverride

Reads Qt::UserRole as a QStringList, fills the combo box, and selects the current value from Qt::EditRole (if present).

Parameters
editorEditor widget previously created by createEditor().
indexModel index being edited.

Definition at line 337 of file dbselectView.h.

◆ setModelData()

void ComboDelegate::setModelData ( QWidget * editor,
QAbstractItemModel * model,
const QModelIndex & index ) const
inlineoverride

The selected text is assigned to Qt::EditRole.

Parameters
editorEditor widget.
modelModel to update.
indexModel index being edited.

Definition at line 364 of file dbselectView.h.

◆ updateEditorGeometry()

void ComboDelegate::updateEditorGeometry ( QWidget * editor,
const QStyleOptionViewItem & option,
const QModelIndex & index ) const
inlineoverride
Parameters
editorEditor widget.
optionStyle option containing the target rectangle.
indexModel index (unused).

Definition at line 381 of file dbselectView.h.


The documentation for this class was generated from the following file: