we have made a new .h and a new .cpp
like
#ifndef TABLEIHALESARTNAMEDELEGATE_H
#define TABLEIHALESARTNAMEDELEGATE_H
#include <QItemDelegate>
#include <QModelIndex>
#include <QObject>
#include <QSize>
#include <QDoubleSpinBox>
#include <QtGui>
{
Q_OBJECT
public:
ComboBoxDelegate
(QObject *parent
= 0);
};
#endif
#ifndef TABLEIHALESARTNAMEDELEGATE_H
#define TABLEIHALESARTNAMEDELEGATE_H
#include <QItemDelegate>
#include <QModelIndex>
#include <QObject>
#include <QSize>
#include <QDoubleSpinBox>
#include <QtGui>
class ComboBoxDelegate : public QItemDelegate
{
Q_OBJECT
public:
ComboBoxDelegate(QObject *parent = 0);
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
};
#endif
To copy to clipboard, switch view to plain text mode
and made our .cpp
#include <QtGui>
#include "tableIhaleSartnameDelegate.h"
{
if (index.column() == 0)
{
// 2nd column is being edited, return a QComboBox as an editor
return editor;
}
}
#include <QtGui>
#include "tableIhaleSartnameDelegate.h"
QWidget *ComboBoxDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
if (index.column() == 0)
{
// 2nd column is being edited, return a QComboBox as an editor
QComboBox *editor = new QComboBox(parent);
return editor;
}
return QItemDelegate::createEditor(parent, option, index);
}
To copy to clipboard, switch view to plain text mode
after that what we should do?
Bookmarks