[Interest] Tree widget: rearrange elements

Jan Kundrát jkt at flaska.net
Wed Aug 29 11:53:38 CEST 2012


On 08/29/12 09:57, Sensei wrote:
> 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...

That's because root.parent() is an invalid index, and your code 
explicitly rejects such drops. Try changing the else branch to 
explicitly test for indexAt(event->pos()) == root and accept such events.

What's the idea behind "reject drops to indexes without a parent"? Looks 
like you're also disabling drops to empty space.

Cheers,
Jan

-- 
Trojita, a fast e-mail client -- http://trojita.flaska.net/



More information about the Interest mailing list