[Qt-interest] QTreeView Drag&Drop issue

Sylvain Pointeau sylvain.pointeau at gmail.com
Sat Aug 15 16:12:00 CEST 2009


if a Qt developer reads me,please note that you are not using the right key
for copy or move an item, you are using CMD (the apple key) and the standard
is ALT

please could you fix this bug for 4.6?

Cheers,
Sylvain

On Fri, Aug 14, 2009 at 8:52 PM, Sylvain Pointeau <
sylvain.pointeau at gmail.com> wrote:

> Hi David, Sean,
> Thank you very much for your answers,
>
> actually I just do drag & drop in the same treeview,
> so I can copy or move an item,
> but in any cases, I only have the (+) icon.
>
> seems a bug for me, just wanted to ask you if it happens to you also, and
> if you have any workaround.
> it should be anyway a built-in functionality.
>
> Cheers,
> Sylvain
>
> On Fri, Aug 14, 2009 at 7:20 PM, David Boosalis <david.boosalis at gmail.com>wrote:
>
>> Sorry for not understanding,
>>
>> In mouseMoveEvent() I got something to work (replace the  "+" pixmap)
>> , but not very robust.
>>
>> ...
>> QPixmap pm(myPixmap);
>> drag = new QDrag(this);
>> ..
>> drag->setDragCursor(pm,Qt::CopyAction)
>>
>> Does not with all pimxaps. For instance did not work with a null
>> pixmap, nor did it work with:
>>
>> QPixmap pm = QCursor(Qt::PointingHandCursor).pixmap();
>>
>> With a valid png pixmap it does work, so maybe make your own "pointer"
>> pixmap and use the setDragCursor() as above.
>>
>>
>>
>> On Fri, Aug 14, 2009 at 9:07 AM, Murphy, Sean M.<sean.murphy at gd-ais.com>
>> wrote:
>> >>  drag = new QDrag(this);
>> >>   drag->setPixmap(myPixmap);
>> >>
>> >> This gives me the "+" along with my icon.
>> >
>> > The original poster DOESN'T want the "+" icon.  He's trying to move an
>> existing item from one spot in the list to another spot on the list.  He's
>> not trying to drop a brand new item onto the list and add it.  However when
>> he starts dragging the existing item to move it, the drag/drop system
>> modifies the cursor to include the "+" icon, which he feels is confusing to
>> his users since they aren't really adding a new item, they are just moving
>> an existing item.
>> >
>> > Sean
>> >
>> >> What about the Qt demo codes, there must be a drag & drop example
>> >> there.  Do these work on your system ?
>> >>
>> >>
>> >>
>> >>
>> >> On Thu, Aug 13, 2009 at 5:39 PM, Sylvain
>> >> Pointeau<sylvain.pointeau at gmail.com> wrote:
>> >>> Hi David,
>> >>> Thanks for your answer,
>> >>> I have absolutely no problem in my code, I am using a abstractModel
>> >>> with my QTreeView but the thing is that the cursor is always the
>> >>> icon
>> >>> (+) even if I press the key "CMD" (to only move the item) this bug
>> >>> is really annoying as it show a bad indication to the users ...
>> >>> do you see what I mean?
>> >>> Cheers,
>> >>> Sylvain
>> >>> On Fri, Aug 14, 2009 at 2:22 AM, David Boosalis
>> >>> <david.boosalis at gmail.com>
>> >>> wrote:
>> >>>>
>> >>>> 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
>> >
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090815/d792cd67/attachment.html 


More information about the Qt-interest-old mailing list