QTreeView custom dropEvent



  • Hello,

    I have a custom QTreeView with this dropEvent:

    if (event->mimeData()->hasFormat(KeyFolder::mimeType()))
        if (event->keyboardModifiers() & Qt::ControlModifier)
        event->ignore();
        else
        {
            event->setDropAction(Qt::MoveAction);
            QTreeView::dropEvent(event);
        }
    

    I am able to move entries into each other but I can not reorder them as i want when they have same parent. How can I reorder items that has same parent? If dropping an item to its parent moves it to the end, it will work for me.

    Thank you


  • Lifetime Qt Champion

    Hi,

    Aren't you looking for the InternalMove drop action ?



  • Sir, since I'm not professional, can you please share me code to use?
    Thank you


  • Lifetime Qt Champion


Log in to reply