[Qt-interest] QTreeView Drag&Drop issue
Murphy, Sean M.
sean.murphy at gd-ais.com
Fri Aug 14 18:07:42 CEST 2009
> 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
More information about the Qt-interest-old
mailing list