Results 1 to 17 of 17

Thread: Drag and Drop problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2006
    Posts
    15

    Question Drag and Drop problem

    Dear fellows,

    i've looked over the forum first and didn' find any possible matching case. I'm trying to do drag and drop over a table view header. i've sub classed the tableview and the headers to implement their dragenterevent and dropevent. Also my model implements minmetype(). but draging is disabled over the header. i donno y, and i've debugged alot. any body got any idea !!!!!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Drag and Drop problem

    Did you set acceptDrops property of the headerview to true? Did you implement mimeData() for your model (provided you want to drag items from the model)?

  3. #3
    Join Date
    Nov 2006
    Posts
    15

    Default Re: Drag and Drop problem

    yes all this stuff done, although my intention is to drop color item from another widget to the header of the tableview to color the columns.
    Last edited by ScoOteR; 19th December 2006 at 14:21.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Drag and Drop problem

    Does the headerview receive dragenter and drop events? You can check that by installing an event filter on the header view.

  5. #5
    Join Date
    Nov 2006
    Posts
    15

    Default Re: Drag and Drop problem

    I've debugged it the header receives the dragenters event but it doesn't enter the drop event as the dropping is disabled as I've mentioned before. and yes i accept the drop action in the drag enters event.

  6. #6
    Join Date
    Nov 2006
    Posts
    15

    Default Re: Drag and Drop problem

    I've tried something else. I've made a simple model which holds some static data and made another widget for it the drop was enabled over this one. Even though both have the same custom table view and custom header and both models implements mimeType. So, what do u think made it work with one model and not the other !!!!!!!!!!!!!!!!!!!!!1

  7. #7
    Join Date
    Nov 2006
    Posts
    15

    Default Re: Drag and Drop problem

    actually I've a new surprise for u all. On debugging I found that it stops @ the break point in the mimeType of my temp small model. and i doesn't in the other model I've been working with for a while. So, I'd really appreciate if any body told me what the heck on earth could make what's happening here make sense !!!!

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Drag and Drop problem

    How did you enable drops for the header? Can you show the actual function call? Or maybe even a minimal compilable example?

  9. #9
    Join Date
    Nov 2006
    Posts
    15

    Default Re: Drag and Drop problem

    i think u didn't see my last post but any way here's the snippets u asked for

    Qt Code:
    1. CHeader::CHeader(QWidget *parent)
    2. : QHeaderView(Qt::Horizontal,parent)
    3. {
    4. ui.setupUi(this);
    5. setAcceptDrops(true);
    6. setDropIndicatorShown(true);
    7. m_table = (CMyTable*)parent;
    8. }
    To copy to clipboard, switch view to plain text mode 

    and here i associate this header to my custom table view
    Qt Code:
    1. CCustomColumnTableView::CCustomColumnTableView(QWidget *parent)
    2. : QTableView(parent)
    3. {
    4. CHeader * temp = new CHeader(this);
    5. setHorizontalHeader(temp);
    6. .
    7. .
    8. }
    To copy to clipboard, switch view to plain text mode 

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Drag and Drop problem

    What about dragEnter and drop events?

  11. #11
    Join Date
    Nov 2006
    Posts
    15

    Default Re: Drag and Drop problem

    Qt Code:
    1. void CHeader::dragEnterEvent(QDragEnterEvent * event)
    2. {
    3. if (event->mimeData()->hasFormat("application/x-color"))
    4. event->acceptProposedAction();
    5. }
    6.  
    7. void CHeader::dropEvent(QDropEvent * event)
    8. {
    9. m_table->dropEvent(event);
    10. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Drag & drop with model/view (Qt4)
    By yogeshm02 in forum Qt Programming
    Replies: 16
    Last Post: 19th September 2011, 20:36
  2. Replies: 7
    Last Post: 8th September 2006, 16:19
  3. Drag and drop outside the application
    By jpn in forum Newbie
    Replies: 7
    Last Post: 27th August 2006, 15:37
  4. Drag and drop revisited
    By Big Duck in forum Newbie
    Replies: 2
    Last Post: 30th June 2006, 16:41
  5. Drag 'n Drop problem
    By kiker99 in forum Qt Programming
    Replies: 4
    Last Post: 16th January 2006, 16:35

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.