Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 5

Qt-interest Archive, November 2007
createEvent not called in delegate


Message 1 in thread

Hi,

I am lost in an apparently trivial problem with a delegate [QT Version
is 4.3.2].
I have a QListView Object and a delegate widget that display two labels
one near the other. It should be very simple, I have followed the
SpinBoxDelegate sample:

lass DoubleItemDelegate : public QItemDelegate
{
	Q_OBJECT;
public:
	DoubleItemDelegate(QObject *parent = 0);
	virtual ~DoubleItemDelegate();
	
	QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
			const QModelIndex &index) const;

	void setEditorData(QWidget *editor, const QModelIndex &index) const;
	void setModelData(QWidget *editor, QAbstractItemModel *model,
			const QModelIndex &index) const;

	void updateEditorGeometry(QWidget *editor,
			const QStyleOptionViewItem &option, const QModelIndex &index) const;

protected:	
};

(cut&pasted from the SpinBoxDelegate sample).
Then, I instantiate my QListView, I setup my model (a
QStandardItemModel), instantiate a delegate be using a proper factory
(...) and finally call list->setItemDelegate (delegate):

	if (itemFactory) {
		qDebug ("Installing new delegate");
		QItemDelegate *delegate = itemFactory->create(list);
		list->setItemDelegate(delegate);
	}

After that I add some data to the model.
I can see my list, but it do not use the delegate, infact while using
qDebug() I can see that the constructor is reached but the createEditor
method is never called.
What am I missing?!?

Thank you very much

Regards,

ing. Federico Fuga

--
 [ signature omitted ]