Hi
I have a QTableWidget and I want to enable Drag & Drop functionality. For that I'm using the following code:
tableWidget->setDragEnabled(true);
tableWidget->setDragDropOverwriteMode(true);
tableWidget->setDefaultDropAction(Qt::CopyAction);
tableWidget->setDragEnabled(true);
tableWidget->setDragDropOverwriteMode(true);
tableWidget->setDragDropMode(QAbstractItemView::DragDrop);
tableWidget->setDefaultDropAction(Qt::CopyAction);
To copy to clipboard, switch view to plain text mode
The Drag & Drop functionality works, but only between other QTableWidgets. It doesn't work between a QTableWidget and a QLineEdit. Is it possible to enable Drag & Drop between QTableWidgets and QLineEdits, too?
Has someone an idea to solve the problem?
EDIT: I already tried overwriting dropEvent, dragMoveEvent and dragEnterEvent. I'm not sure what to do, but simply calling event->acceptProposedAction(); or calling event->accept(); doesn't work.
If I use the following code and try do drop some text from any text field (e. g. the address bar in my browser) my application terminates (segmentation fault).
{
event->acceptProposedAction();
}
void DragAndDropTableWidget::dragEnterEvent(QDragEnterEvent *event)
{
event->acceptProposedAction();
}
To copy to clipboard, switch view to plain text mode
(I'm using the Linux Version of Qt 5.0.1)
Bookmarks