Quantcast
Channel: Installation and Deployment
Viewing all articles
Browse latest Browse all 22112

QTreeWidget find parent, current item, old parent in dropEvent

$
0
0
I have a QTreeWidget that supports drop & drops. To prevent invalid drop & drops, I need to find out where the item was taken from, where it is going, and what item was taken. Currently I do this: void dropEvent(QDropEvent *event){         QTreeWidgetItem * pItem = itemAt( event->pos() );         QTreeWidgetItem * oldpItem = itemFromIndex( oldModel );//oldModel is set earlier         QTreeWidgetItem * cItem;         QString source = event->source()->objectName();         for(int i=0;i<oldpItem->childCount();i++){             QTreeWidgetItem * item = oldpItem->child(i);             if (item->text(0) == source){                 cItem = item;                 break;             }         } The current item is what I am unable to find. This approach crashes at the moment. Is there a simpler way to get what item is being moved?

Viewing all articles
Browse latest Browse all 22112

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>