[Interest] DragDrop between different processes not working?

Wilhelm wilhelm.meier at fh-kl.de
Wed Dec 17 11:34:45 CET 2014


Am 17.12.2014 um 10:52 schrieb Jason H:
> It's been a while but I've dragged content out of browser (Firefox) into a Qt app. It works, at least back in Qt 4.x.

Works here too ... the other way is the problem.

> 
> You have to enable DnD events. Your app won't respond to them otherwise.

What do you mean exactly?

> 
>> Sent: Wednesday, December 17, 2014 at 1:18 AM
>> From: Wilhelm <wilhelm.meier at fh-kl.de>
>> To: "interest at qt-project.org" <interest at qt-project.org>
>> Subject: [Interest] DragDrop between different processes not working?
>>
>> Hi all,
>>
>> below is a stripped-down example for drag/drop. It follows the Qt
>> examples. It works if I drag from the ListView widget to another widget
>> (e.g. QTextEdit) of the same(!) process. But it doesn't work if I drag
>> to another(!) process - with the same programm or another, e.g. kate.
>>
>> So, obviously I'm missing something to enable drag/drop between
>> processes. But I can't figure out what - I think it must be very basic!
>>
>> Can anyone help?
>>
>>
>> void ListView::mouseMoveEvent(QMouseEvent* event)
>> {
>>     TRACE;
>>     if (!(event->buttons() & Qt::LeftButton)) {
>>         return;
>>     }
>>     if ((event->pos() - mMousePressPosition).manhattanLength() <
>> QApplication::startDragDistance()) {
>>         return;
>>     }
>>     QDrag* drag = new QDrag(this);
>>     QMimeData* mimeData = new QMimeData;
>>
>>     mimeData->setText(QString::fromLatin1("ABC"));
>>     mimeData->setUrls(QList<QUrl>() << QUrl::fromLocalFile("./test.cc"));
>>
>>     drag->setMimeData(mimeData);
>>
>>     qDebug() << Q_FUNC_INFO << mimeData->text();
>>     qDebug() << Q_FUNC_INFO << mimeData->urls();
>>
>>     Qt::DropAction dropAction = drag->exec(Qt::CopyAction |
>> Qt::MoveAction, Qt::CopyAction);
>>
>>     qDebug() << Q_FUNC_INFO << "drop:" << dropAction;
>> }
>>
>> -- 
>> Wilhelm
>> w.meier at unix.net
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
> 


-- 
Wilhelm
w.meier at unix.net



More information about the Interest mailing list