⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)

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

  • Lifetime Qt Champion

    You would override the dragX function and use startDrag to begin the operation.

    please see this

    The area to the left is a list and code shows how its done.

    class PiecesList : public QListWidget
        explicit PiecesList(int pieceSize, QWidget *parent = 0);
        void addPiece(QPixmap pixmap, QPoint location);
        static QString puzzleMimeType() { return QStringLiteral("image/x-puzzle-piece"); }
        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;

Log in to reply