1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| QWidget * SoundDelegate::createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const
{
switch(index.column())
{
case 0: // Id
...
...
case 5: // File
{
URLEdit * editor = new URLEdit(parent);
return editor;
}
}
}
void SoundDelegate::setEditorData(QWidget * editor, const QModelIndex & index) const
{
switch(index.column())
{
case 0:
...
...
case 5:
{
QString text = index.model()->data(index, Qt::EditRole).toString();
URLEdit * line_edit = static_cast<URLEdit *>(editor);
line_edit->setText(text);
}
return;
}
}
void SoundDelegate::setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const
{
switch(index.column())
{
case 0:
...
...
case 5:
{
URLEdit * line_edit = static_cast<URLEdit *>(editor);
QString text = line_edit->text();
model->setData(index, text, Qt::EditRole);
}
return;
}
}
void SoundDelegate::updateEditorGeometry(QWidget * editor, const QStyleOptionViewItem & option, const QModelIndex & index) const
{
editor->setGeometry(option.rect);
} |
Partager