新建一个类ReadOnlyDelegate,头文件为ReadOnlyDelegate .h
#ifndef READONLYDELEGATE_H
#define READONLYDELEGATE_H
#endif // READONLYDELEGATE_H
#include<QItemDelegate>
class ReadOnlyDelegate : public QItemDelegate
{
Q_OBJECT
public:
ReadOnlyDelegate(QObject *parent = 0): QItemDelegate(parent) { }
QWidget *createEditor(QWidget*parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
return NULL;
}
};