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 between QTableWidgets
QtWS25 Last Chance

Drag and Drop between QTableWidgets

Scheduled Pinned Locked Moved Solved General and Desktop
qtablewidgetdrag and drop
2 Posts 1 Posters 1.3k 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.
  • O Offline
    O Offline
    Olivier Ronat
    wrote on 15 Dec 2015, 10:01 last edited by SGaist
    #1

    I want to know how to retrieve the source QTableWIdget of a drag and drop operation
    when reimplementing the dropMimeData(int row, int column, const QMimeData *data, Qt::DropAction action) method.

    Answer : I find it in the DropEvent->source but how to get the row & column coordinates of the DragItem?

    O 1 Reply Last reply 15 Dec 2015, 18:29
    1
    • O Olivier Ronat
      15 Dec 2015, 10:01

      I want to know how to retrieve the source QTableWIdget of a drag and drop operation
      when reimplementing the dropMimeData(int row, int column, const QMimeData *data, Qt::DropAction action) method.

      Answer : I find it in the DropEvent->source but how to get the row & column coordinates of the DragItem?

      O Offline
      O Offline
      Olivier Ronat
      wrote on 15 Dec 2015, 18:29 last edited by
      #2

      I finally solved the issue in reimplementing the dropEvent like that :
      if (event) {
      // Get QTableWidget
      QTableWidget *table = qobject_cast<QtableWidget *>(event->source());

      // Decode Mime Data
      QString format = QLatin1String("application/x-qabstractitemmodeldatalist");
      QByteArray encoded = event->mimeData()->data(format);
      QDataStream stream(&encoded, QIODevice::ReadOnly);

      // Decode format (row, column) to get row & column coordinates
      int row,column;
      stream >> row >> column;
      }

      1 Reply Last reply
      1

      2/2

      15 Dec 2015, 18:29

      • Login

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