Hi,

Versuche gerade in ein QTableWidget ein QComboBox einzufügen. Dazu habe ich mir ein QItemDelegate abgeleitet:
Code:
class MyDelegate : public QItemDelegate
{
 public:
	MyDelegate(QObject* parent=0);

	QWidget *createEditor(QWidget*, const QStyleOptionViewItem&, const QModelIndex&) const;
	void setEditorData(QWidget*, const QModelIndex&) const;
	void setModelData(QWidget*, QAbstractItemModel*, const QModelIndex&) const;
};
mit folgender Implentierung:

Code:
MyDelegate::MyDelegate(QObject* parent) : QItemDelegate(parent)
{
}

QWidget* MyDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
	QWidget* editor = 0;

				QComboBox* combo = new QComboBox(parent);
				combo->addItems(value.toStringList());
				editor = combo;
	
	editor->installEventFilter(const_cast<MyDelegate*>(this));
	return editor;
}

void MyDelegate::setEditorData(QWidget *editor, const QModelIndex& index) const
{
	QVariant value = index.model()->data(index, Qt::DisplayRole);

				QComboBox* combo = static_cast<QComboBox*>(editor);
				combo->setCurrentIndex(combo->findText(value.toString()));
}

void MyDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
{
	QVariant value;

				QComboBox *combo = static_cast<QComboBox*>(editor);
				QStringList list;
				list << combo->currentText();
				combo->removeItem(combo->findText(combo->currentText()));
				for (int i=0; i<combo->count(); i++)
					{
						list << combo->itemText(i);
					}
				value = list;

	model->setData(index, value);
}
Nun soweit klappt es das wenn man Doppelkick zum editieren drauf drückt die QComboBox erscheint. Nur direkt beim Start oder nach dem Editieren zeigt QTableWidget kein Text an. Er soll halt das erste Element also combo->currentText() im Feld anzeigen bei den anderen die ich mal überschrieben habe funktioniert das automatisch z.B. bei QCheckbox oder QSpinBox. Wie kann ich das mit QComboBox unter Qt4 machen?
Hoffe jemand hat sich mit Qt4 schon beschäftigt

MfG
xmarvel