QListView & item movement

Hi,
I have a QListView and it's a listview for showing the queue in my music player project. I have two problems:

first: i want the user to be able to move the items up and down by draging and droping them. I set the dragDropMode to internalMove and the dafaultDropAction to targetMoveAcion but when I run the app and move the items they go into each other.
what can I do about that? (QListWidget doesn't have this problem)

second: I need to know which Item is moved and where is it moved to so I can be able to update the QMediaPlayer->playList(). how can I do that?

@SGaist I mean when you move the Item in QListView you can drop the item between two items or on another item. when you drop it on another item the other item disappears and the moved item takes its place. I think it replaces the item's data

and also I need to know where the index is moved to. is that possible?

@SGaist
I create a queueModel and set the listView's model to queue model. the Items in queueModel have a few userRole data. this is the slot that connets to doubleClicked signal on a track that I have in my trackModel:

Hi @asanka424@SGaist
I was able to set the item flags correctly but now I'm having problem with item changed signal.
How do I know where was the Item (it's row) before it was moved? (I can set the item's data to hold the current row but isn't there a better way?)

And also I was searching the QStandardItemModel's signals to find something useful and I found QStandardItemModel::rowsMoved(...) and QStandardItemModel::rowsAboutToBeMoved(...) and I tried them but they don't ge triggred when an item is moved. why is that?

Beware of such handling of flags!

It's a very wrong way to do it. If the flag is not set you'll actually enable it, additionally it doesn't work with compound flags! Suppose you have (in binary) a = 010 and b = 110, then a ^ b == 100 which is very different from the expected 000.

The proper way to remove a set of bits is to AND the inversion:a & ~b == 000
/and this can be rigorously proven to be different from a ^ b if you expand the xor in the other basic operations a ^ b = (a & ~b) | (~a & b)/

Even if we accept, as the basic tenet of true democracy, that one moron is equal to one genius, is it necessary to go a further step and hold that two morons are better than one genius?

Hi @asanka424@kshegunov
Sorry for replying late.
an interesting thing happened:
when I set the flags of the items to
queueModel->item(i)->setFlags(queueModel->item(i)->flags() & !Qt::ItemIsDropEnabled);
the items get disabled!
bot when I do:
queueModel->item(i)->setFlags(queueModel->item(i)->flags() ^ Qt::ItemIsDropEnabled);
the is no problem. I think I'm doing something wrong.

ANd I will try:
queueView->setDragEnabled(false);
and get back with a result. thank all of you for answering again. I love this from and the people who answer the questions