PDA

View Full Version : QAbstractItemModel and drags&drops problem [or maybe I am the problem?]



roro
22nd June 2007, 08:30
Hi,

This is a mail I sent to QT-support :


I have a little problem with QTreeView management of drag&drops :
To illustrate this, I join to this mail the QT-SimpleTreeModel example modified to show that :

Writing in my QAbstractItemModel::flags() :
-------------
if (!index.isValid())
return Qt::ItemIsEnabled;

if (! index.parent().isValid())
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled ;

return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
---------------
I expected to enable the drops only on non-toplevel items.
But what I got is : enable drops only on CHILDREN of non-toplevel items.
In the example, we can traduce that by :
I can start draging for instance the item "Getting started" but I can't drop it onto "Designing a component/creating a dialog".
However, I can drop it on "Form Editing Mode / Layouts / The grid layout"

I hope I am understandable, please forgive my bad english I'm a french guy :-(

I don't know if it is a bug ? If it is a wanted feature, could you indicate me how can I have the result I expected ?

The support engineer told me that he managed to perform a drop onto for instance "Designing a component/creating a dialog" :confused:, that is forbidden (but I expected that would be allowed) when I execute the example program on my computer (UNIX kubuntu gutsy, QT 4.3.0).
Could you tell me if on other platforms all works perfectly or I someone can reproduce my bug ? or tell me what's wrong in my code or my vision of flags and drags&drops ?
Thanks :)
Romain

guilugi
22nd June 2007, 09:52
Hey, maybe I can help you directly via MSN, I'm French too ;-)

roro
25th June 2007, 14:58
Hello,

I do not have MSN at work, but if you want to help me trough this forum, it's ok :)
What does my program do with you ?

guilugi
25th June 2007, 19:48
Ok ok, I'll check this out tomorrow then (sorry, I forgot about this thread :p)

roro
27th June 2007, 16:52
Up, could someone help me please ? It's just compiling my program and trying a drag and drop...

guilugi
27th June 2007, 16:53
I'm currently compiling ;-)

guilugi
27th June 2007, 17:01
Okay, test done !

Well, it's forbidden to drop the item on top-level items, but I can drop it on child items...
I mean the cursor is not a forbidden sign...

But I can't drop it anyway, it seems I'm allowed to drop it on child items, but it's not effective.

Hope this helps.

roro
28th June 2007, 16:54
Thanks guilugi :)

But I don't understand why I am the only one having a forbidding icon when I try a drop on children of toplevels items :crying:

Anyway, I resolved my problem making tests in my dropMimeData() method. Not very beautiful, but...

Thanks for your help :)