Skip to Content

Welcome, I'm Shantanu Tushar, currently pursuing B.E. in Computer Science And Engineering at B.M.S. College Of Engineering, Bangalore. You'll find here mostly, apart from my personal details, technical stuff that I am able to put on here. Please share your views and comments in the Feedback section.
Please note that all content here is the best to my knowledge, and I do not take responsibility for any direct/indirect loss caused by following the text herein.

Qt

Drag and Drop in Qt 4.5

ecently I was working on a Qt app requiring Drag and Drop support. The documentation says that to use this on a QWidget, we need to set
dialog.setAcceptDrops(true);
I tried that but the cursor still showed the "not -allowed" symbol. This was bit confusing making me think that there's some internal problem. But actually the implementation of the following event handlers is mandatory to make it work-
 

void Dialog::dragEnterEvent(QDragEnterEvent *event)

Stray '/' in path when querying MIME url list in Qt Drag and Drop

In Qt, when an object is dropped onto a widget the following event handler is to be used to get the list of URLs of the dropped objects-
 

void Dialog::dropEvent(QDropEvent *event)

{

if (mimeData->hasUrls()) {

QList urlList = mimeData->urls();

qDebug() << urlList.at(0).path();

Syndicate content