QListWidget Drag and Drop problem
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:
Code:
setDragEnabled( true );
viewport()->setAcceptDrops( true );
setDropIndicatorShown( true );
I've derived a mousePressEvent method which I'm keeping really simple at this point:
Code:
void ModifyParamSetListWidget
::mousePressEvent( QMouseEvent *event
) {
if ( !anItem )
{
event->ignore();
return;
}
if ( event->button() == Qt::LeftButton )
{
mimeData->setText( anItem->data( Qt::DisplayRole).toString() );
drag->setMimeData( mimeData );
Qt::DropAction dropAction = drag->exec( Qt::CopyAction );
}
else
{
}
return;
}
I'm just adding adding standard list widget items to the list.
Code:
item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsDragEnabled );
item->setText( itsName );
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