I'm trying to implement Drag & Drop using a QTableWidget and I haven't been having much luck. I've been trying to get a hold of the QTableWidgetItem that the cursor is over using the itemAt(int x, int y) function using the QMouseEvent event but I keep getting a NULL pointer.

Qt Code:
  1. void table_widget::mousePressEvent(QMouseEvent *event) {
  2. QMenu *popupMenu = new QMenu(this);
  3. popupMenu->addAction("Drag");
  4. popupMenu->addAction("Drop");
  5.  
  6. if (event->button() == Qt::RightButton) {
  7. popupMenu->popup(QPoint(event->x()+216,event->y()+130), 0);
  8. printf("%x\n",itemAt(event->x()+216,event->y()+130));
  9. }
  10. }
To copy to clipboard, switch view to plain text mode 

The 216 and 130 are just offsets from the top left corner of the GUI to the top left corner of the first cell in the table.

Any suggestions?