[Qt-interest] QListWidgetItem in Drag n' drop
Marcelo Estanislau Geyer
estanisgeyer at hotmail.com
Mon Mar 30 19:16:45 CEST 2009
Hi friends,
I have a configuration dialog of the toolbar on my application.
See image in http://www.standardnet.com.br/dndTR.png
My items are working (moved) between QListWidgets subclass. I need is that when drag the item "Separator" (see the image) to
another QListWidget subclass, the action is to copy and not to move, and drag the item back ("Separator" only), just remove it but not doing anything to target.
See the sample code below:
ListAct :: ListAct(QWidget * parent)
:QListWidget ( parent )
{
setViewMode( QListView::ListMode ) ;
setSelectionMode( QAbstractItemView::SingleSelection ) ;
setDragEnabled( true ) ;
viewport()->setAcceptDrops( true ) ;
setDropIndicatorShown( true ) ;
setMovement( QListView::Snap ) ;
setUniformItemSizes( true ) ;
setDragDropMode( QAbstractItemView::DragDrop ) ;
}
ListAct::~ListAct()
{
}
void ListAct::addAct()
{
QListWidgetItem *sep = new QListWidgetItem( this ) ;
sep->setText( QString::fromUtf8( "--- Separator ---" )) ;
sep->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled ) ;
QListWidgetItem *item = new QListWidgetItem( this ) ;
item->setText(QString::fromUtf8( "ItemTest1" )) ;
item->setIcon(QIcon( ":/imagens/clients.png" )) ;
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled) ;
QListWidgetItem *item2 = new QListWidgetItem(this) ;
item2->setText(QString::fromUtf8("ItemTest2")) ;
item2->setIcon(QIcon(":/imagens/clients.png")) ;
item2->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled) ;
}
Qt::DropActions ListAct::supportedDropActions() const
{
return Qt::MoveAction ;
}
Thanks,
Marcelo Estanislau Geyer
_________________________________________________________________
Windows Live Messenger. O melhor em multitarefa.
http://www.microsoft.com/windows/windowslive/products/messenger.aspx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090330/d51699f7/attachment.html
More information about the Qt-interest-old
mailing list