Drag & Drop Question: "Accessing QMimeData directly"



  • I am implementing some drag and drop functionality for which I created a QMimeData subclass that has a pointer attribute to some self defined object. So far, I have been able to get things working up to retrieving this attribute back from my QMimeData class. I have looked at the 3rd approach explained over here on passing custom data for a drag event: http://doc.qt.io/qt-5/qmimedata.html My problem is that I do not understand what "// access myData's data directly (not through QMimeData's API)" means in this example. I cannot use myData->myFunctionToAccessTheData() which is implemented to return the pointer I need. The problem originates from the const in the cast "qobject_cast<const MyMimeData *>(event->mimeData());". Any ideas how to go around this?



  • I got it to work with a const_cast ...


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.