Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

Using QTreeWidget drag & drop with QDomDocument

$
0
0
Hi everyone, In my application, I have a QTreeWidget that allows the user to reorganize the ordering of its items by dragging and dropping them. I also have a QDomDocument that represents the structure of the QTreeWidget, so when the user moves an item, I want the position of the nodes in the QDomDocument to be updated to reflect this new arrangement. The nodes are uniquely identified by their attributes. What functions do I need to use or reimplement to accomplish this? I found the QDomNode::insertBefore() and insertAfter() functions, so it seems like I just need to remove the node from its original position and then call insertBefore() or insertAfter() to put it in its new position. I think I need to reimplement QTreeWidget::dropEvent, and then do the QDom updating in there. But how can I detect the original position and the new position of the node inside dropEvent? Thanks for any help you can give.

Viewing all articles
Browse latest Browse all 18427

Trending Articles