[Interest] Tree widget: rearrange elements

Tibold Kandrai dom at dotzteam.com
Wed Aug 29 10:53:30 CEST 2012


Hi,

You can try to set flags on the invisibleRootItem:
http://doc.qt.nokia.com/4.7-snapshot/qstandarditemmodel.html#invisibleRootItem

I never used this, but it worth a try. :)

Tibold

On 2012-08-29 09:57, Sensei wrote:
> 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!
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest


-- 
Tibold Kandrai
CEO @ Dotz Team




More information about the Interest mailing list