The item delegate:
Qt Code:
  1. class MyItemDelegate : public QItemDelegate
  2. {
  3. Q_OBJECT
  4. public:
  5. MyItemDelegate();
  6. ~MyItemDelegate();
  7. virtual QSize sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const;
  8. virtual void paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const;
  9. private:
  10. QSize mSize;
  11. };
To copy to clipboard, switch view to plain text mode 

The item:
Qt Code:
  1. class MyTreeWidgetItem : public QTreeWidgetItem
  2. {
  3. public:
  4. enum DataRole
  5. {
  6. TextRole = Qt::UserRole + 1,
  7. //other roles
  8. };
  9. MyTreeWidgetItem(... );
  10. ~MyTreeWidgetItem();
  11. QVariant data( int role )const;
  12. };
To copy to clipboard, switch view to plain text mode 

The paint method should be something like:
Qt Code:
  1. void MyItemDelegate::paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const
  2. {
  3. const QAbstractItemModel* model = index.model();
  4. QString text = model->data(index, MyTreeWidgetItem::TextRole).toString();
  5.  
  6. //here draw the item and the expand handle
  7. //BTW - you should keep a refernece to it's rect for when it is clicked
  8. }
  9.  
  10. This is a basic impl. You can add things to it according to your needs.
To copy to clipboard, switch view to plain text mode