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

后端 未结 1 1604
礼貌的吻别
礼貌的吻别 2021-02-10 04:11

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:57

    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)
提交回复
热议问题