Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Drag and drop items from one list widget to another

Drag and drop items from one list widget to another

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Im_ArunV
    wrote on last edited by A Former User
    #1

    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

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      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.html

      The 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;
      };
      
      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved