QT5.6 QTableWidget Drag and drop mode can be used. only "InternalMove" mode has effect when use setDragDropMode



  • I try to made a class Inherited from QTableWidget and it's event.
    The drag and drop can be used only on internalMove mode, why can be used by DragDrop mode.
    Code:
    h file
    class MyListTabel:public QTableWidget
    { Q_OBJECT
    public:
    explicit MyListTabel(QWidget *parent=0);
    protected:
    void dragEnterEvent(QDragEnterEvent *e);
    void dropEvent(QDropEvent *e);
    // void dragMoveEvent(QDragMoveEvent *e);

    };

    cpp file

    MyListTabel::MyListTabel(QWidget *parent){
    this->setAcceptDrops(true);
    this->setDragEnabled(true);
    this->setDropIndicatorShown(true);
    this->setDragDropMode(QAbstractItemView::InternalMove); //DragDrop
    }

    void MyListTabel::dragEnterEvent(QDragEnterEvent *e){
    e->setAccepted(true);
    e->setDropAction(Qt::MoveAction);
    e->acceptProposedAction();
    }
    void MyListTabel::dropEvent(QDropEvent *e)
    {
    if(this!=e->source()){
    MyPoint3d InsertP;
    this->setFocus();
    .....................


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.