Results 1 to 6 of 6

Thread: Drag And Drop Woooees

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2008
    Location
    Canada
    Posts
    10
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Unhappy Drag And Drop Woooees

    Hi,

    I don't get it.... I have a QtableView in a dlg form, connected to a sql datasource recordset. the data displays fine, no problems. The problem is that i cannot drag a row from this view and drop it onto its parent window.

    The table view is getting every signal except for dragMoveEvent

    I've declared everything correctly, but still nothing. NOW.... if i change from QTableView to QTableWidget, dragging works!!, but i can then no longer use myView->setModel(mysqlset).

    in .h
    Qt Code:
    1. class QDrag;
    2. ....
    3.  
    4. protected:
    5. QDrag *getDragObject(QMouseEvent *event);
    6.  
    7. void dragEnterEvent(QDragEnterEvent *event);
    8. void dropEvent(QDropEvent *event);
    9. void dragMoveEvent(QDragMoveEvent * event);
    To copy to clipboard, switch view to plain text mode 

    in .cpp
    Qt Code:
    1. // initialization
    2. DlgLibraryEditor::DlgLibraryEditor(QWidget * parent, QSqlDatabase m_pPrimarydb) : QDialog(parent), Ui::DlgLibraryEditor()
    3. {
    4. setupUi(this);
    5.  
    6. //setup properties for table
    7. m_pMusicTableView->setSelectionBehavior(QAbstractItemView::SelectRows);
    8. m_pMusicTableView->setSelectionMode(QAbstractItemView::ExtendedSelection);
    9. m_pMusicTableView->viewport()->setAcceptDrops(false);
    10. m_pMusicTableView->viewport()->setAttribute(Qt::WA_StaticContents);
    11.  
    12. //Drag and drop setup
    13. m_pMusicTableView->setDragEnabled(true);
    14. m_pMusicTableView->setDragDropMode(QAbstractItemView::DragOnly);
    15. m_pMusicTableView->setDropIndicatorShown(true);
    16. m_pMusicTableView->setAcceptDrops(true);
    17.  
    18. ...
    19. }
    20.  
    21. void DlgLibraryEditor::dragEnterEvent(QDragEnterEvent * event)
    22. {
    23. event->ignore();
    24. }
    25.  
    26. void DlgLibraryEditor::dragMoveEvent(QDragMoveEvent * event)
    27. {
    28. event->ignore();
    29. }
    30.  
    31. void DlgLibraryEditor::dropEvent(QDropEvent * event)
    32. {
    33. event->ignore();
    34. }
    To copy to clipboard, switch view to plain text mode 

    what gives ???

    Thanks,
    Johnny
    Attached Files Attached Files
    Last edited by sticcino; 3rd July 2008 at 01:21. Reason: added addtional explaination

Similar Threads

  1. Problem with a cursor during Drag and Drop
    By mtrpoland in forum Qt Programming
    Replies: 1
    Last Post: 28th December 2007, 15:46
  2. Strange behavior with Drag and Drop (not always drops)
    By Mona Shokrof in forum Qt Programming
    Replies: 1
    Last Post: 27th May 2007, 18:00
  3. Drag and Drop
    By allensr in forum Qt Programming
    Replies: 1
    Last Post: 11th December 2006, 20:50
  4. Replies: 7
    Last Post: 8th September 2006, 16:19
  5. Drag and drop revisited
    By Big Duck in forum Newbie
    Replies: 2
    Last Post: 30th June 2006, 16:41

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
  •  
Qt is a trademark of The Qt Company.