Hi there,

I'd like to change the cursor pixmap during my drag & drop event.
Drag & drop works perfectly, its only the pixmap I don't know how to change...

I use a QTableView with a subclassed QSqlRelationalTableModel as my model. To enable dragevents I use the m_tableView->setDragEnabled(true) function.

I know u can set the Pixmap using
Qt Code:
  1. QDrag *drag = new QDrag(this);
  2. drag->setPixmap(QPixmap(":/images/drag.png"));
To copy to clipboard, switch view to plain text mode 
but I don't know, where to use these lines (inside my model, or somewhere else?) or how to do taht exactly?

hope somebody has a solution...

here's the model I'm using:

Qt Code:
  1. #ifndef MYQSQLRELATIONALTABLEMODEL_H
  2. #define MYQSQLRELATIONALTABLEMODEL_H
  3.  
  4. #include <QSqlRelationalTableModel>
  5. #include <QMimeData>
  6. #include <QByteArray>
  7. #include <QDataStream>
  8.  
  9. class MyQSqlRelationalTableModel : public QSqlRelationalTableModel
  10. {
  11. Q_OBJECT
  12. public:
  13. MyQSqlRelationalTableModel(QObject * parent = 0, QSqlDatabase db = QSqlDatabase()) : QSqlRelationalTableModel(parent, db){}
  14.  
  15. Qt::DropActions supportedDropActions() const
  16. {
  17. return Qt::CopyAction;
  18. }
  19.  
  20. Qt::ItemFlags flags(const QModelIndex &index) const
  21. {
  22. Qt::ItemFlags defaultFlags = QAbstractTableModel::flags(index);
  23.  
  24. if (index.isValid())
  25. return Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags;
  26. else
  27. return Qt::ItemIsDropEnabled | defaultFlags;
  28. }
  29.  
  30. QMimeData *mimeData(const QModelIndexList &indexes) const
  31. {
  32. QMimeData *mimeData = new QMimeData();
  33. QByteArray encodedData;
  34. QDataStream stream(&encodedData, QIODevice::WriteOnly);
  35.  
  36. ... //encode my data
  37.  
  38. mimeData->setData("myMimeData", encodedData);
  39. return mimeData;
  40. }
  41. };
  42. #endif
To copy to clipboard, switch view to plain text mode 

regards
darksaga