Item delegate that edits a cell using a QComboBox populated from Qt::UserRole.
More...
#include <dbselectView.h>
|
| | 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.
|
| |
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.
◆ ComboDelegate()
| ComboDelegate::ComboDelegate |
( |
QObject * | parent = nullptr | ) |
|
|
inlineexplicit |
- Parameters
-
| parent | Optional Qt parent object. |
Definition at line 307 of file dbselectView.h.
◆ 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
-
| parent | Parent widget for the editor. |
| option | Style options (unused). |
| index | Model 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
-
| editor | Editor widget previously created by createEditor(). |
| index | Model 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
-
| editor | Editor widget. |
| model | Model to update. |
| index | Model 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
-
| editor | Editor widget. |
| option | Style option containing the target rectangle. |
| index | Model index (unused). |
Definition at line 381 of file dbselectView.h.
The documentation for this class was generated from the following file: