Override the "no drop sign" when doing drag to desktop
Hi,
I would like to implement behaviour like in latest versions of firefox, where a user can drag a tab to the desktop and a new application is started.
I've almost figured out all i need to make it happen except for the "stop sign" that appears under the cursor when dragging stuff to the desktop...
In the code, i have the following mousemove event where the drag is implemented:
Code:
{
if (!(event->buttons() & Qt::LeftButton))
{
// Wrong buttn, no drag
return;
}
if ((event
->pos
() - dragStartPosition
).
manhattanLength() <
QApplication::startDragDistance()) {
// Distance too small, no drag yet !
return;
}
if (event->buttons() & Qt::LeftButton )
{
pixmap->grabWidget( this );
drag->setMimeData(mimeData);
drag->setPixmap( *pixmap );
Qt::DropAction dropAction = drag->exec(Qt::MoveAction);
if( t )
{
// there is a target....
}
else
{
// no target...
tmp->show();
}
delete drag;
delete pixmap;
}
}
Any ideas on how to override or remove the stop-sign below the cursor ?
Thanks !
Re: Override the "no drop sign" when doing drag to desktop
Have you tried adding a Shell IDList Array to your mimedata? It's an array of PIDLs uniquely identifying the object/s. The shelll always uses objects rather than files or other things as they can specify virtual files and folders.
Re: Override the "no drop sign" when doing drag to desktop
Hi, thanks for your reply.
How would i do that ?
Use void setMimeData ( QMimeData * data )
on the QDrag, with a subclass of QMimeData ... but fill it with what ?
Re: Override the "no drop sign" when doing drag to desktop
Re: Override the "no drop sign" when doing drag to desktop
how would you do this ?
You have to give me more to go on.... :)
Re: Override the "no drop sign" when doing drag to desktop
Ok, create a QByteArray, fill it in like it says via that link, and then pass it to QMimeData::setData with a type of "Shell IDList Array". The data depends on what you want to transfer to the shell object (what you are dragging).
If you want source code of how to do that, well, Firefox is open-source :) Qt classes will not help you here.