240717班级,工业化控制系统,煤矿相关行业,昆仑系统
congmu
2024-10-31 ad2a36a8425406799db94a2e26d1fba82db6aa60
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
#include "qcomboxdelegate.h"
 
 
 
QComBoxDelegate::QComBoxDelegate()
{
 
}
 
QComBoxDelegate::QComBoxDelegate(QObject *p):QItemDelegate(p)
{
 
}
 
QWidget *QComBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    QComboBox * box = new QComboBox(parent);
    QStringList text;
    text << "普通采矿员工" << "技术维护人员" << "系统管理员"<< "安全管理人员";
    box->addItems(text);
 
    return box;
}
 
void QComBoxDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    QRect rec = option.rect;
    editor->setGeometry(rec);
}
 
void QComBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
 
}
 
void QComBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
    QString val = static_cast<QComboBox *>(editor)->currentText();
    model->setData(index,val);
}