Hi,

I'm working on a project where I need to drag data from one QListWidget to another and I'm missing something simple. When I select an item to drag it's being marked/displayed as forbidden. I'm stumped as to why.

I have a class derived from QListWidget. In the constructor I set:

Qt Code:
  1. setDragEnabled( true );
  2. viewport()->setAcceptDrops( true );
  3. setDragDropMode( QAbstractItemView::DragDrop );
  4. setDropIndicatorShown( true );
To copy to clipboard, switch view to plain text mode 

I've derived a mousePressEvent method which I'm keeping really simple at this point:
Qt Code:
  1. void ModifyParamSetListWidget::mousePressEvent( QMouseEvent *event )
  2. {
  3. QListWidgetItem *anItem = itemAt( event->pos() );
  4. if ( !anItem )
  5. {
  6. event->ignore();
  7. QListWidget::mousePressEvent( event);
  8. return;
  9. }
  10. if ( event->button() == Qt::LeftButton )
  11. {
  12. QDrag *drag = new QDrag( this );
  13. QMimeData *mimeData = new QMimeData;
  14. mimeData->setText( anItem->data( Qt::DisplayRole).toString() );
  15. drag->setMimeData( mimeData );
  16. Qt::DropAction dropAction = drag->exec( Qt::CopyAction );
  17. }
  18. else
  19. {
  20. QListWidget::mousePressEvent( event );
  21. }
  22. return;
  23. }
To copy to clipboard, switch view to plain text mode 

I'm just adding adding standard list widget items to the list.
Qt Code:
  1. item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsDragEnabled );
  2. item->setText( itsName );
To copy to clipboard, switch view to plain text mode 

The problem I'm having is that when I select an item in the list to drag it's being marked as forbidden. I can't figure out what I've missed. I think it's something simple and obvious I'm just missing it. Can anyone help me out here?

thanks