Re: [Interest] Tree widget: rearrange elements

2012-08-29 Thread Sensei
On 8/29/12 11:53am, Jan Kundrát wrote: > 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. Cool, now I get root to accept drops! Thanks!

Re: [Interest] Tree widget: rearrange elements

2012-08-29 Thread Jan Kundrát
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

Re: [Interest] Tree widget: rearrange elements

2012-08-29 Thread Sensei
On 8/29/12 10:53am, Tibold Kandrai wrote: > 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. :) It would be cool, but it doesn't work... invisibleRootItem()-

Re: [Interest] Tree widget: rearrange elements

2012-08-29 Thread Tibold Kandrai
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! >> >> Se

Re: [Interest] Tree widget: rearrange elements

2012-08-29 Thread Sensei
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

Re: [Interest] Tree widget: rearrange elements

2012-08-27 Thread Tibold Kandrai
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. Cheers, Tibold On 2012-08-27 12:33, Sensei wrote: > On 8/27/12 10:59am, Tibold Kandrai wrote: >> Hi, >> >> As I understood the task is this: >> You wa

Re: [Interest] Tree widget: rearrange elements

2012-08-27 Thread Sensei
On 8/27/12 10:59am, Tibold Kandrai wrote: > Hi, > > As I understood the task is this: > You want Qt to handle the drag and drop, but you want to control whether > you can or cannot drop the item. > > For this you need to override one of the drag events not the drop event. > I think you need to use

Re: [Interest] Tree widget: rearrange elements

2012-08-27 Thread Tibold Kandrai
Hi, As I understood the task is this: You want Qt to handle the drag and drop, but you want to control whether you can or cannot drop the item. For this you need to override one of the drag events not the drop event. I think you need to use this: http://doc.qt.nokia.com/4.7-snapshot/qtreeview.htm

[Interest] Tree widget: rearrange elements

2012-08-27 Thread Sensei
Dear all, I am now messing around my own QTreeWidget. I'm trying to let rearrangement of items possible, allowing or disallowing drop events. Obviously it doesn't work, otherwise I wouldn't seek your help! :) Test case: in a tree there are "folders" and "files", and I can move files on folders