I might have found a bug in Qt 4.1.

QTreeWidget::setItemWidget(), which was introduced in Qt 4.1 allows a widget to be displayed in an tree item's cell.

An example code below creates a simple QTreeWidget with 10 rows and 2 columns.
The first column contains item's index as text and the second column contains a QLabel with same text, respectively.

Qt Code:
  1. tree->setColumnCount(2);
  2.  
  3. for (int i = 0; i < 10; ++i) {
  4. item->setText(0, QString::number(i));
  5. tree->addTopLevelItem(item);
  6. tree->setItemWidget(item, 1, new QLabel(QString::number(i)));
  7. }
To copy to clipboard, switch view to plain text mode 

Resizing the QTreeWidget small enough to get the vertical scrollbar visible and then scrolling back and forth messes up the item widget drawing in the second column. Though, resize event seems to fix the erroneous drawing.




- JP