Results 1 to 4 of 4

Thread: Enable Drag & Drop between QTableWidget and QLineEdit

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2012
    Posts
    132
    Thanks
    10
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Question Enable Drag & Drop between QTableWidget and QLineEdit

    Hi

    I have a QTableWidget and I want to enable Drag & Drop functionality. For that I'm using the following code:

    Qt Code:
    1. tableWidget->setDragEnabled(true);
    2. tableWidget->setDragDropOverwriteMode(true);
    3. tableWidget->setDragDropMode(QAbstractItemView::DragDrop);
    4. 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).
    Qt Code:
    1. void DragAndDropTableWidget::dragEnterEvent(QDragEnterEvent *event)
    2. {
    3. event->acceptProposedAction();
    4. }
    To copy to clipboard, switch view to plain text mode 

    (I'm using the Linux Version of Qt 5.0.1)
    Last edited by Infinity; 31st March 2013 at 22:14.

Similar Threads

  1. How to customize Drag and Drop for QTableWidget?
    By linxs in forum Qt Programming
    Replies: 0
    Last Post: 17th November 2012, 17:56
  2. Drag & Drop rows in a QTableWidget
    By vycke in forum Qt Programming
    Replies: 7
    Last Post: 19th January 2012, 01:01
  3. Drag and drop reordering in a QTableWidget
    By Lendrick in forum Qt Programming
    Replies: 1
    Last Post: 23rd November 2009, 00:19
  4. Drag and Drop QTableWidget and QTableView
    By scorpion11 in forum Qt Programming
    Replies: 5
    Last Post: 8th April 2008, 10:33
  5. Drag & Drop using QTableWidget
    By Israa in forum Qt Programming
    Replies: 21
    Last Post: 12th April 2007, 20:35

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.