Results 1 to 2 of 2

Thread: cursor pixmap during drag&drop

  1. #1
    Join Date
    Jan 2007
    Posts
    68
    Thanks
    9
    Thanked 8 Times in 8 Posts

    Question cursor pixmap during drag&drop

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: cursor pixmap during drag&drop

    Unfortunately the model architecture doesn't support that currently (Qt4.3).

Similar Threads

  1. Replies: 20
    Last Post: 16th August 2008, 00:19
  2. Replies: 4
    Last Post: 17th June 2007, 11:30
  3. Problem with drag&drop in qlistview
    By mambo in forum Qt Programming
    Replies: 2
    Last Post: 11th September 2006, 17:14
  4. Drag&Drop with QStandardItemModel
    By madcat in forum Qt Programming
    Replies: 4
    Last Post: 7th May 2006, 16:43

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.