Results 1 to 6 of 6

Thread: Override the "no drop sign" when doing drag to desktop

  1. #1

    Default 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:
    Qt Code:
    1. void CMyTabBar::mouseMoveEvent(QMouseEvent *event)
    2. {
    3.  
    4. if (!(event->buttons() & Qt::LeftButton))
    5. {
    6. // Wrong buttn, no drag
    7. return;
    8. }
    9. if ((event->pos() - dragStartPosition).manhattanLength() < QApplication::startDragDistance())
    10. {
    11. // Distance too small, no drag yet !
    12. return;
    13. }
    14.  
    15. if (event->buttons() & Qt::LeftButton )
    16. {
    17. QDrag *drag = new QDrag(this);
    18. QMimeData *mimeData = new QMimeData;
    19. QPixmap* pixmap = new QPixmap(100,100);
    20.  
    21. pixmap->grabWidget( this );
    22.  
    23. drag->setMimeData(mimeData);
    24. drag->setPixmap( *pixmap );
    25.  
    26. Qt::DropAction dropAction = drag->exec(Qt::MoveAction);
    27.  
    28. QWidget* t = drag->target () ;
    29. if( t )
    30. {
    31. // there is a target....
    32. }
    33. else
    34. {
    35. // no target...
    36. QWidget* tmp = new SomeWidget();
    37. tmp->show();
    38.  
    39. }
    40. delete drag;
    41. delete pixmap;
    42. }
    43. }
    To copy to clipboard, switch view to plain text mode 

    Any ideas on how to override or remove the stop-sign below the cursor ?

    Thanks !

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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.

  3. #3

    Default 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 ?

  4. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Override the "no drop sign" when doing drag to desktop


  5. #5

    Default 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....

  6. #6
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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.

Similar Threads

  1. Drag and Drop from a list to a form
    By orbital_fox in forum Qt Programming
    Replies: 0
    Last Post: 1st October 2009, 18:29
  2. drag and drop QToolButton in QToolBar
    By NBilal in forum Qt Programming
    Replies: 1
    Last Post: 28th December 2008, 20:11
  3. Change cursor & status during Drag & Drop
    By ronlongo in forum Qt Programming
    Replies: 0
    Last Post: 1st December 2008, 16:56
  4. Drag & Drop when parent and childs accept drops?
    By gri in forum Qt Programming
    Replies: 0
    Last Post: 17th October 2008, 09:00
  5. Drag and drop revisited
    By Big Duck in forum Newbie
    Replies: 2
    Last Post: 30th June 2006, 16:41

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.