You'll have to subclass from QListView and overload the dropEvent
//Enabling the drops for the list viewport
list->viewport()->setAcceptDrops( true );
void FileExplorerList
::dropEvent( QDropEvent *event
) {
[INDENT]if ( event->mimeData()->hasUrls() )
{
[INDENT]
//Getting the dir model of the list
QDirModel *dirModel
= qobject_cast<QDirModel
*>
( list
->model
() );
//Dropping the mime data
dirModel->dropMimeData( event->mimeData(), event->proposedAction(), parentIndex );
//Note: it's up to you to get the parent index for the drop operation[/INDENT]
}[/INDENT]}
//Enabling the drops for the list viewport
list->viewport()->setAcceptDrops( true );
void FileExplorerList::dropEvent( QDropEvent *event )
{
[INDENT]if ( event->mimeData()->hasUrls() )
{
[INDENT]
//Getting the dir model of the list
QDirModel *dirModel = qobject_cast<QDirModel*>( list->model() );
//Dropping the mime data
dirModel->dropMimeData( event->mimeData(), event->proposedAction(), parentIndex );
//Note: it's up to you to get the parent index for the drop operation[/INDENT]
}[/INDENT]}
To copy to clipboard, switch view to plain text mode
This should work fine. Actually, there is QDirModel::setReadOnly( bool ) method as well. I'm not sure about it, but setting it to on might possible enable the default drop functionality for the dir model.
Bookmarks