[Interest] Tree widget: rearrange elements

Sensei senseiwa at gmail.com
Wed Aug 29 09:57:06 CEST 2012


On 8/27/12 12:37pm, Tibold Kandrai wrote:
> Hi,
>
> Nice catch!
>
> Set the flag since that you have to do that only when creating the item
> and I guess Qt internally it will check the flag anyway.


Hi again!

Having succeeded in this, now I'm facing a new challenge: limit the drop 
to a tree.

I have a root in the tree, and every item is a child of that. If I 
drag/drop items, I can rearrange things.

Except that no item should be dropped at the same level of root.

For instance:

root
  |
  +- first
  |    |
  |    +- a.txt
  |    +- b.txt
  |
  +- second
       |
       +- c.txt

I hoped that having a valid parent could be OK, and if I use this 
method, I can drop to children of root:


void txProjectView::dragMoveEvent(QDragMoveEvent *event)
{
     if (indexAt(event->pos()).parent().isValid())
     {
         event->accept();
     }
     else
     {
         event->ignore();
     }
}


Unfortunately, I cannot drop on root!

I am missing something really stupid here...




Thanks & Cheers!





More information about the Interest mailing list