I have a little problem with DnD using a QListWidget.
I have to create my own QListWidget class (called CListWidget) as I need to implement my own mousePressEvent method.

Qt Code:
  1. void CListWidget::mousePressEvent(QMouseEvent *event)
  2. {
  3. QListWidget::mousePressEvent(event);
  4.  
  5. if ( currentItem()->text().isEmpty() )
  6. {
  7. clearSelection();
  8. return;
  9. }
  10.  
  11. QByteArray itemData;
  12. QDataStream dataStream(&itemData, QIODevice::WriteOnly);
  13. dataStream << currentItem()->text();
  14.  
  15. QMimeData *mimeData = new QMimeData;
  16. mimeData->setData("application/x-dnditemdata", itemData);
  17. mimeData->setText(currentItem()->text());
  18.  
  19. QDrag *drag = new QDrag(this);
  20. drag->setMimeData(mimeData);
  21. drag->exec(Qt::CopyAction);
  22. }
To copy to clipboard, switch view to plain text mode 

When using this code, I cannot see any text while dragging.
If I comment the code and just enable the drag:

Qt Code:
  1. CListWidget::CListWidget(QWidget* parent) : QListWidget(parent)
  2. {
  3. setDragEnabled(true);
  4. }
To copy to clipboard, switch view to plain text mode 

the text of the CListWidget item is shown while dragging.

Why ?

The problem is also that, if I use the QT default drag, I don't have any text in the item dragged.

Thanks for any suggestion


PS: Using Qt version 4.4.0 under Linux Ubuntu 8.04