Drag and drop items from one list widget to another
-
how to implement drag and drop items from one QListWidget to another without using predefined Qt Designer settings,atleast provide some hint how to implement drop event in QListWidget??
wanted to implement a feature if listwidget contains drop item(lets say "abc") already wanna rename newly dropped item to abc_2 for this not able to find the dropevent on a listwidget -
Hi
You would override the dragX function and use startDrag to begin the operation.please see this
http://doc.qt.io/qt-5/qtwidgets-draganddrop-puzzle-example.htmlThe area to the left is a list and code shows how its done.
class PiecesList : public QListWidget { Q_OBJECT public: explicit PiecesList(int pieceSize, QWidget *parent = 0); void addPiece(QPixmap pixmap, QPoint location); static QString puzzleMimeType() { return QStringLiteral("image/x-puzzle-piece"); } protected: void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE; void dragMoveEvent(QDragMoveEvent *event) Q_DECL_OVERRIDE; void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE; void startDrag(Qt::DropActions supportedActions) Q_DECL_OVERRIDE; int m_PieceSize; };