[Qt-interest] QTreeView Drag&Drop issue
David Boosalis
david.boosalis at gmail.com
Fri Aug 14 15:36:57 CEST 2009
Drag and drop works for me on Linux. I set my own drag icon:
drag = new QDrag(this);
drag->setPixmap(myPixmap);
This gives me the "+" along with my icon.
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
>> > _______________________________________________
>> > 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