Results 1 to 3 of 3

Thread: Hide drag and drop icon

  1. #1
    Join Date
    May 2013
    Posts
    304
    Thanks
    9
    Thanked 7 Times in 7 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Hide drag and drop icon

    Hi all,
    When you drag and drop from a QListView or QTreeView you have the cursor + the icon or the row of the tree.
    Is it possible to hide and only keep the cursor when the drag and drop is in a QWidget ?
    Thanks for the help

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,595
    Thanks
    13
    Thanked 1,588 Times in 1,517 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Hide drag and drop icon

    Does QDrag::setPixmap() with an empty QPixmap do it?

  3. The following user says thank you to ChrisW67 for this useful post:

    Alundra (17th June 2014)

  4. #3
    Join Date
    May 2013
    Posts
    304
    Thanks
    9
    Thanked 7 Times in 7 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Hide drag and drop icon

    Thanks, that works using this code :
    Qt Code:
    1. class CListView : public QListView
    2. {
    3. public:
    4.  
    5. CListView( QWidget* Parent ) :
    6. QListView( Parent )
    7. {
    8. }
    9.  
    10. protected:
    11.  
    12. virtual void startDrag( Qt::DropActions supportedActions )
    13. {
    14. QDrag Drag( this );
    15. const QModelIndexList indexes = selectedIndexes();
    16. Drag.setMimeData( model()->mimeData( indexes ) );
    17. Drag.exec( supportedActions );
    18. }
    19. };
    To copy to clipboard, switch view to plain text mode 
    Is it possible to only hide the pixmap when it's outside of the QListView ?
    Maybe "dragLeaveEvent ( QDragLeaveEvent * e )" is a way to think about but then "QDrag Drag( this );" has to be stored ?
    But still the problem of "m_DetailList->setViewMode( QListView::IconMode );".
    It's impossible to drag and drop internaly using QListView with IconMode.
    Using "QListView::ListMode" that works normally.
    I hope you know the solution.

    EDIT : Apparently it's because "m_DetailList->setMovement( QListView::Static );"
    But without it, you can move items that is not good for what I do, does a way exist to just allow drag and drop but not move ?
    Thanks

    EDIT2 : Here the solution of the Static problem :
    Qt Code:
    1. m_DetailList->setMovement( QListView::Snap );
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. virtual void dropEvent( QDropEvent* e )
    2. {
    3. if( indexAt( e->pos() ).isValid() )
    4. QListView::dropEvent( e );
    5. else
    6. e->ignore();
    7. }
    To copy to clipboard, switch view to plain text mode 
    I do all that under your control, say me if what I do is not correct.
    Last edited by Alundra; 17th June 2014 at 04:32.

Similar Threads

  1. Replies: 1
    Last Post: 25th May 2011, 21:20
  2. Drag & Drop to Systray icon
    By ahmed.helal in forum Qt Programming
    Replies: 0
    Last Post: 21st December 2010, 16:34
  3. QPainter crash when generating icon after drag-drop
    By craigTheBrit in forum Qt Programming
    Replies: 3
    Last Post: 16th November 2010, 08:52
  4. Replies: 20
    Last Post: 15th August 2008, 23:19
  5. Icon Change in Drag & Drop
    By joseph in forum Qt Programming
    Replies: 1
    Last Post: 9th December 2006, 12:03

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.