1. Есть делегат Delegate.
2. Есть виджет Widget - наследник QWidget. Delegate работает с Widget.
Почему при редактировании ничего не происходит? Если же Delegate будет использовать QSpinBox напрямую, то все работает!?
Вот компилируемый код:
#include <QtCore/QDebug>
#include <QtGui/QApplication>
#include <QtGui/QItemDelegate>
#include <QtGui/QLayout>
#include <QtGui/QSpinBox>
#include <QtGui/QTreeWidgetItem>
class Widget : public QWidget
{
public:
   Widget( QWidget* parent ) : QWidget( parent )
   {
      _box = new QSpinBox( this );
      _box->setRange( 0, 100 );
      QHBoxLayout* layout = new QHBoxLayout;
      layout->addWidget( _box );
      setLayout( layout );
   }
   QSize sizeHint() const
   {
      return QSize( 100, 100 );
   }
   void setValue( const int value )
   {
      _box->setValue( value );
   }
   int value() const
   {
      return _box->value();
   }
private:
   QSpinBox* _box;
};
class Delegate : public QItemDelegate
{
public:
   Delegate( QObject* parent = 0 ) : QItemDelegate( parent ) {}
   ~Delegate() {}
   QWidget* createEditor( QWidget* parent, const QStyleOptionViewItem&, const QModelIndex& ) const
   {
      Widget* widget = new Widget( parent );
      return widget;
   }
   void setEditorData( QWidget* editor, const QModelIndex& ) const
   {
      ( (Widget*)editor )->setValue( 1 );
   }
   void updateEditorGeometry( QWidget* editor,   const QStyleOptionViewItem& option, const QModelIndex& ) const
   {
      editor->setGeometry( option.rect );
   }
};
int main( int argc, char** argv )
{
   QApplication app( argc, argv );
   QTreeWidget widget;
   widget.setColumnCount( 1 );
   widget.setItemDelegate( new Delegate( &widget ) );
   QTreeWidgetItem* item = new QTreeWidgetItem( &widget );
   item->setText( 0, "asdfaga" );
   item->setFlags( item->flags() | Qt::ItemIsEditable );
   app.setActiveWindow( &widget );
   widget.show();
   return app.exec();
}