[Qt-interest] QTreeView Drag&Drop issue

David Boosalis david.boosalis at gmail.com
Fri Aug 14 02:22:52 CEST 2009


I have the used the following code to accept drag & drop, somethings
may not make sense to youas they relate to my code, but it may give
you some clues as to your problem.

-David

PS - if still having trouble, paste some of your code in a email

setDragDropMode(QAbstractItemView::DragDrop);
setDropIndicatorShown(true);
...
/*********************************************************************/
void MyTreeWidget::dragEnterEvent( QDragEnterEvent *de)
{
  qDebug("Drage Enter Event....");
  if (de->mimeData()->hasFormat("Student")) {
    qDebug("Accept drag event ....");
    dragMode = MyEnumValue;
    de->acceptProposedAction();
  }
  else
    qDebug("DO NOT ACCEPT");
}
/*********************************************************************/
void MyTreeWidget::dragMoveEvent(QDragMoveEvent *dm)
{
  dm->acceptProposedAction();
}
/*********************************************************************/
void MyTreeWidget::dropEvent(QDropEvent *event)
{
  QStringList strList;
  QString str;
  bool okay;


  QByteArray byteArray;
  const QMimeData *mimeData;
 .....
  // if (event->proposedAction() == Qt::CopyAction) {
  event->acceptProposedAction();
  mimeData = event->mimeData();
  if (mimeData == 0) {
      qWarning("Invalid drop - mime data = 0");
      return;
  }
 if (mimeData->hasFormat("Student")) {

    byteArray = mimeData->data("Student");
    QDataStream ds(&byteArray,QIODevice::ReadWrite);

    ds >> studentList;
    emit droppedStudents(studentList);
  }
  QTreeWidget::dropEvent(event);


On Thu, Aug 13, 2009 at 3:54 PM, Sylvain
Pointeau<sylvain.pointeau at gmail.com> wrote:
> Hello,
> I have an issue on the drag and drop for a tree view on Macosx
> The cursor is always a (+) even if we only move an item (with CMD pressed
> (should be alt by the way))
> what should I do for this bug to be solved?
> Cheers,
> Sylvain
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>



More information about the Qt-interest-old mailing list