Qt Drag and Drop QListView removing the item on which it is released

后端 未结 1 479
轮回少年
轮回少年 2021-02-10 04:24

I working on a small QlistView which is Sortable.

    iListView = new QListView(this);
    //Creating a standard item model
    iStandardModel = new QStandardItem         


        
相关标签:
1条回答
  • 2021-02-10 04:45

    That is because by default QStandardItem has Qt::ItemIsDropEnabled flag set. Just remove it by using QStandardItem::setFlags() function. Add following lines:

    item1->setFlags(item1->flags() ^ (Qt::ItemIsDropEnabled));
    item2->setFlags(item2->flags() ^ (Qt::ItemIsDropEnabled));
    item3->setFlags(item3->flags() ^ (Qt::ItemIsDropEnabled));
    
    iListView->showDropIndicator(); // For convenience..
    
    0 讨论(0)
提交回复
热议问题