Thanks guys for your answer, I really appreciate.

@Spitfire: you are right, that's basically what I am trying to achieve. I have checked my code, I don't disable the indicator anywhere. Unfortunately it's not easy to make a compilable example, some work is involved, but I will do it if I can't find any solution soon.
I have overriden the paint event, however currently all it does is calling the base class (QtTreeWidget) paint method. So that's not the problem.

@ugluk: the flags seems to be fine, I added the piece of code below for each created item, the flag returned by flags() is 61 (decimal) and its value is not modified by the line just below:

Qt Code:
  1. Qt::ItemFlags flag = pItem->flags();
  2. flag |= Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
  3. pItem->setFlags(flag);
To copy to clipboard, switch view to plain text mode 

Below the full relevant code of my class:

Qt Code:
  1. //////////////////////////////////////////////////////////////////////////
  2.  
  3. class imQMimeData : public QMimeData
  4. {
  5. public :
  6.  
  7. imQMimeData () : QMimeData ()
  8. {
  9. m_eDropAction = Qt::MoveAction;
  10. }
  11.  
  12. virtual ~imQMimeData () {}
  13.  
  14. imNode* GetNode(void) const { return m_pNode; }
  15. void SetNode(imNode* _pNode) { m_pNode = _pNode; }
  16.  
  17. QTreeWidgetItem* GetItem(void) const { return m_pItem; }
  18. void SetItem(QTreeWidgetItem* _pItem) { m_pItem = _pItem; }
  19.  
  20. imU32 GetOldIndex() const { return m_nOldIndex; }
  21. void SetOldIndex(imU32 _nIndex) { m_nOldIndex = _nIndex; }
  22.  
  23. public :
  24.  
  25. imNode* m_pNode;
  26. QTreeWidgetItem* m_pItem;
  27. imU32 m_nOldIndex;
  28. Qt::DropAction m_eDropAction;
  29. };
  30.  
  31. //////////////////////////////////////////////////////////////////////////
  32.  
  33. imGuiSceneExplorer::imGuiSceneExplorer(QWidget * parent) : QTreeWidget(parent), imIStreamingCallback()
  34. {
  35. m_pScene = imNULL;
  36. m_bBuildingTree = imFALSE;
  37. m_pUI = imNULL;
  38. }
  39.  
  40.  
  41. //////////////////////////////////////////////////////////////////////////
  42.  
  43. imGuiSceneExplorer::~imGuiSceneExplorer()
  44. {
  45. clear();
  46. }
  47.  
  48. //////////////////////////////////////////////////////////////////////////
  49.  
  50. void imGuiSceneExplorer::SetUI(Ui::imGuiMainWindowClass* _pUI)
  51. {
  52. m_pUI = _pUI;
  53.  
  54. setColumnCount(2);
  55.  
  56. headerItem()->setText(0, tr("Name"));
  57. headerItem()->setText(1, tr("Type"));
  58.  
  59. header()->setResizeMode(0, QHeaderView::ResizeToContents);
  60. header()->setResizeMode(1, QHeaderView::ResizeToContents);
  61.  
  62. // drag & drop
  63. setAcceptDrops(imTRUE);
  64. setDragEnabled(true);
  65. setDragDropMode(DragDrop);
  66. setDragDropOverwriteMode(imFALSE);
  67. setDropIndicatorShown(imTRUE);
  68.  
  69. setSelectionMode(QAbstractItemView::SingleSelection);
  70. setSelectionBehavior(QAbstractItemView::SelectRows);
  71.  
  72. // context menu
  73. setContextMenuPolicy(Qt::CustomContextMenu);
  74. connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ShowTreeContextMenu(const QPoint&)));
  75. }
  76.  
  77. //////////////////////////////////////////////////////////////////////////
  78.  
  79. QSize imGuiSceneExplorer::sizeHint() const
  80. {
  81. QSize theSize(256, 768);
  82. return theSize;
  83. }
  84.  
  85. //////////////////////////////////////////////////////////////////////////
  86.  
  87. void imGuiSceneExplorer::SelectNode(imNode* _pNode)
  88. {
  89. while (*it)
  90. {
  91. imNode* pNode = GetNodeFromItem(*it);
  92. if (pNode == _pNode)
  93. {
  94. setCurrentItem(*it);
  95.  
  96. if (m_pScene)
  97. m_pScene->SetSelectedNode(_pNode);
  98.  
  99. return;
  100. }
  101. ++it;
  102. }
  103. }
  104.  
  105. //////////////////////////////////////////////////////////////////////////
  106.  
  107. imNode* imGuiSceneExplorer::GetNodeFromItem(QTreeWidgetItem* _pItem)
  108. {
  109. if (!_pItem)
  110. return imNULL;
  111. return *(imNode**)_pItem->data(0, Qt::UserRole).toByteArray().constData();
  112. }
  113.  
  114. //////////////////////////////////////////////////////////////////////////
  115.  
  116. void imGuiSceneExplorer::BuildContent( imScene* _pScene )
  117. {
  118. clear();
  119.  
  120. m_pScene = _pScene;
  121. if (!_pScene)
  122. return;
  123.  
  124. // create top level item
  125. m_bBuildingTree = imTRUE;
  126. imNode* pRoot = _pScene->GetRootNode();
  127. AddNodeItem(pRoot, imNULL, -1);
  128. m_bBuildingTree = imFALSE;
  129. }
  130.  
  131. //////////////////////////////////////////////////////////////////////////
  132.  
  133. QTreeWidgetItem* imGuiSceneExplorer::CreateItemFromNode(imNode* _pNode)
  134. {
  135. imAssert(_pNode);
  136. if (_pNode)
  137. {
  138. QTreeWidgetItem* pItem = imNew QTreeWidgetItem();
  139. Qt::ItemFlags flag = pItem->flags();
  140. flag |= Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
  141. pItem->setFlags(flag);
  142.  
  143. // node name
  144. imStringBase sName(_pNode->GetName().GetLength() ? _pNode->GetName() : _pNode->RTTIGetClass()->getName());
  145. QString sQName = QString::fromWCharArray((const wchar_t*)sName);
  146. pItem->setText(0, sQName);
  147.  
  148. // node type
  149. imStringBase sType(_pNode->RTTIGetClass()->getName());
  150. QString sQType = QString::fromWCharArray((const wchar_t*)sType);
  151. pItem->setText(1, sQType);
  152.  
  153. // set data
  154. QByteArray data((const char *)&_pNode, sizeof(_pNode));
  155. QVariant oVariant(data);
  156. pItem->setData( 0, Qt::UserRole, oVariant);
  157.  
  158. return pItem;
  159. }
  160. return imNULL;
  161. }
  162.  
  163. //////////////////////////////////////////////////////////////////////////
  164.  
  165. void imGuiSceneExplorer::rowsInserted ( const QModelIndex & parent, int start, int end )
  166. {
  167. if (!m_bBuildingTree)
  168. {
  169. QTreeWidgetItem* pItemParent = itemFromIndex(parent);
  170. if (pItemParent)
  171. {
  172. imNode* pParent = GetNodeFromItem(pItemParent);
  173. if (pParent)
  174. {
  175. for (imInt i = start; i <= end; ++i)
  176. {
  177. QTreeWidgetItem* pItemChild = pItemParent->child(i);
  178. imNode* pChild = GetNodeFromItem(pItemChild);
  179. pParent->InsertChild(pChild, i);
  180. }
  181. }
  182. }
  183. }
  184.  
  185. QTreeWidget::rowsInserted(parent,start,end);
  186. }
  187.  
  188. //////////////////////////////////////////////////////////////////////////
  189.  
  190. void imGuiSceneExplorer::rowsAboutToBeRemoved ( const QModelIndex & parent, int start, int end )
  191. {
  192. if (!m_bBuildingTree)
  193. {
  194. QTreeWidgetItem* pItemParent = itemFromIndex(parent);
  195. imNode* pParent = GetNodeFromItem(pItemParent);
  196.  
  197. for (imInt i = start; i <= end; ++i)
  198. {
  199. QTreeWidgetItem* pItemChild = pItemParent->child(i);
  200. imNode* pChild = GetNodeFromItem(pItemChild);
  201. pParent->RemoveChild(i, imFALSE);
  202. }
  203. }
  204.  
  205. QTreeWidget::rowsAboutToBeRemoved(parent,start,end);
  206. }
  207.  
  208. //////////////////////////////////////////////////////////////////////////
  209.  
  210. QMimeData *imGuiSceneExplorer::mimeData(const QList<QTreeWidgetItem *> items) const
  211. {
  212. imAssert(items.size());
  213. if (items.size())
  214. {
  215. imQMimeData *mimeData = imNew imQMimeData();
  216. imNode* pNode = *(imNode**)items[0]->data(0, Qt::UserRole).toByteArray().constData();
  217. mimeData->SetNode(pNode);
  218. mimeData->SetItem(items[0]);
  219. mimeData->SetOldIndex(items[0]->parent() ? items[0]->parent()->indexOfChild(items[0]) : 0);
  220.  
  221. return mimeData;
  222. }
  223. return imNULL;
  224. }
  225.  
  226. //////////////////////////////////////////////////////////////////////////
  227.  
  228. bool imGuiSceneExplorer::dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action)
  229. {
  230. if (action == Qt::IgnoreAction)
  231. return true;
  232.  
  233. if (parent)
  234. {
  235. const imQMimeData* myData = static_cast<const imQMimeData *>(data);
  236. if (myData && parent != myData->GetItem())
  237. {
  238. imNode* pNode = myData->GetNode();
  239. AddNodeItem(pNode, parent, index);
  240. }
  241. }
  242. return true;
  243. }
  244.  
  245. //////////////////////////////////////////////////////////////////////////
  246.  
  247. void imGuiSceneExplorer::dragEnterEvent ( QDragEnterEvent * event )
  248. {
  249. QTreeWidget::dragEnterEvent(event);
  250.  
  251. event->accept();
  252. }
  253.  
  254. //////////////////////////////////////////////////////////////////////////
  255.  
  256. void imGuiSceneExplorer::dragMoveEvent ( QDragMoveEvent * event )
  257. {
  258. QTreeWidget::dragMoveEvent(event);
  259.  
  260. event->accept();
  261. }
  262.  
  263. //////////////////////////////////////////////////////////////////////////
  264.  
  265. void imGuiSceneExplorer::paintEvent( QPaintEvent* event )
  266. {
  267. QTreeWidget::paintEvent (event);
  268. }
  269.  
  270. //////////////////////////////////////////////////////////////////////////
  271.  
  272. void imGuiSceneExplorer::OnItemSelected()
  273. {
  274. // do something
  275. }
  276.  
  277. //////////////////////////////////////////////////////////////////////////
To copy to clipboard, switch view to plain text mode