?? mapdelegate.cpp
字號:
#include <QtGui>
#include "mapdelegate.h"
MapDelegate::MapDelegate(QObject *parent)
: QItemDelegate(parent)
{
}
void MapDelegate::setEditorData(QWidget *editor,
const QModelIndex& index) const
{
if(index.column() == 0) // company
{
QComboBox *comboEditor = qobject_cast<QComboBox *>(editor);
if (comboEditor) {
int i = comboEditor->findText(index.model()->data(index, Qt::EditRole).toString());
comboEditor->setCurrentIndex(i);
}
}
else
return QItemDelegate::setEditorData(editor, index);
}
void MapDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex& index) const
{
if(index.column() == 0)
{
QComboBox *comboBox = qobject_cast<QComboBox *>(editor);
if(comboBox)
{
model->setData(index, comboBox->currentText());
}
}
else
return QItemDelegate::setModelData(editor, model, index);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -