Finding the end of a drag and drop operation in a QAbstractItemView

I created my own proxy model inherited by QSortFilterProxyModel. My original model for the aforementioned proxy model is also a custom model inherited by QAbstractTableModel. Then I set my own proxy model in QTableView.

In this custom proxy model, I reimplemented the mimeData (..) function. This is as follows.

QMimeData* CustomProxyModel::mimeData( const QModelIndexList & rListIndexes ) const { QMimeData *pMimeData = new QMimeData(); //some code here connect(pMimeData, SIGNAL( destroyed(QObject*) ), this, SLOT( OnDestroyDraggedItem() ) ); return pMimeData; } 

In Qt4.7, shortly after a user drops a QTableView element somewhere, the OnDestroyDraggedItem () slot is called. In other words, the QMimeData object is deleted shortly after the drag operation.

But in Qt 5.1, the OnDestroyDraggedItem () slot is never called. In other words, the QMimeData object is never deleted after a drag operation.

Am I doing something wrong? Or does Qt 5.1 have a memory leak after a drag operation? Is there any other way to find a drag operation?

+1
source share
1 answer

It may be a little late, but can't you just inherit QMimeData and do something in the destructor? There should be a small and safe code, of course - throwing exceptions in destructors can cause strange behavior :)

0
source

All Articles