Hi fellow hackers!

In QT-4.1.4, I'm trying to drop something on A QTreeWidget's headerItem(), with little success.

In the short example below, I can drag "Node 1" and "Node 2" and drop them on each other, but QT won't let me drop on the headerItem ("Node 0") even though I've set its ItemIsDropEnabled-flag. What can be done?

Qt Code:
  1. #include <QApplication>
  2. #include <QTreeWidgetItem>
  3.  
  4. #define S(qstring) (qstring).toLatin1().constData()
  5.  
  6. class Tree : public QTreeWidget
  7. {
  8. public:
  9. Tree() : QTreeWidget() {
  10. setColumnCount(1);
  11. setDragEnabled(true);
  12. setAcceptDrops(true);
  13. }
  14. bool dropMimeData(QTreeWidgetItem *droppedOn, int, const QMimeData *, Qt::DropAction) {
  15. qDebug("Something dropped on %s", S(droppedOn->text(0)));
  16. return true;
  17. }
  18. };
  19.  
  20.  
  21. int main( int argc, char **argv )
  22. {
  23. QApplication app( argc, argv );
  24.  
  25. QTreeWidget *tree = new Tree;
  26.  
  27.  
  28. i = new QTreeWidgetItem(tree);
  29. i->setText(0, "Node 1");
  30. i->setFlags(i->flags() | Qt::ItemIsDropEnabled);
  31.  
  32. i = new QTreeWidgetItem(tree);
  33. i->setText(0, "Node 2");
  34. i->setFlags(i->flags() | Qt::ItemIsDropEnabled);
  35.  
  36. tree->headerItem()->setText(0,"Node 0");
  37. tree->headerItem()->setFlags(tree->headerItem()->flags() | Qt::ItemIsDropEnabled);
  38.  
  39. tree->show();
  40. app.exec();
  41. return 0;
  42. }
To copy to clipboard, switch view to plain text mode