Results 1 to 6 of 6

Thread: Preventing drop/drag outside the main window

  1. #1
    ucomesdag Guest

    Question Preventing drop/drag outside the main window

    Qt Code:
    1. void floorBoard::dragMoveEvent(QDragMoveEvent *event)
    2. {
    3. QByteArray data = event->mimeData()->data("text/uri-list");
    4. QString uri(data);
    5.  
    6. if ( event->mimeData()->hasFormat("application/x-stompbox") ||
    7. uri.contains(".syx", Qt::CaseInsensitive) &&
    8. event->answerRect().intersects(this->geometry()) )
    9. {
    10. if (children().contains(event->source()))
    11. {
    12. event->setDropAction(Qt::MoveAction);
    13. event->accept();
    14. } else {
    15. event->acceptProposedAction();
    16. };
    17. } else {
    18. event->ignore();
    19. };
    20. };
    To copy to clipboard, switch view to plain text mode 

    I tried with adding event->answerRect().intersects(this->geometry()) but you can still drag items outside the mainwindow?

    Bit lost here, I want the drag to stop when we are outside the window but it is still active when moving over other apps like firefox.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Preventing drop/drag outside the main window

    Change the mime data type of the drag event.
    If you want only your application should handle the drag drop event, use some mime data type which other applications dont understand.

  3. #3
    ucomesdag Guest

    Default Re: Preventing drop/drag outside the main window

    Quote Originally Posted by aamer4yu View Post
    Change the mime data type of the drag event.
    If you want only your application should handle the drag drop event, use some mime data type which other applications dont understand.
    Uh like? Even "snork" as mime type works on some greedy apps they just take everything
    Last edited by ucomesdag; 26th February 2007 at 05:34.

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Preventing drop/drag outside the main window

    Quote Originally Posted by ucomesdag View Post
    Uh like? Even "snork" as mime type works on some greedy apps they just take everything
    hmm... i am not sure how to disable the drag and drop of other application from your application. But one thing more I can suggest.
    You can check the window/ widget which accepted the drop by drag->target() function. Hence based on the window that accepted the drag, you can perform actions in your application. Hope this might help you

  5. The following user says thank you to aamer4yu for this useful post:


  6. #5
    ucomesdag Guest

    Default Re: Preventing drop/drag outside the main window

    Quote Originally Posted by aamer4yu View Post
    You can check the window/ widget which accepted the drop by drag->target() function. Hence based on the window that accepted the drag, you can perform actions in your application.
    Sorry ain't working either, I can still drop my widgets on firefox.

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

    Default Re: Preventing drop/drag outside the main window

    Setting "Snork" is not enough (should be application/x-snork anyway). You have to make sure there are no other mime-types set, especially text/plain. How do you create the drag in the first place?

Similar Threads

  1. move parent window to the front.
    By hvengel in forum Qt Programming
    Replies: 4
    Last Post: 2nd February 2007, 09:41
  2. Main window with custom buttons ?
    By probine in forum Qt Programming
    Replies: 1
    Last Post: 22nd November 2006, 07:32
  3. Replies: 5
    Last Post: 5th August 2006, 00:44
  4. cannot make a main window modal
    By Dark_Tower in forum Qt Programming
    Replies: 12
    Last Post: 23rd March 2006, 11:21
  5. Main window
    By Michiel in forum Qt Tools
    Replies: 1
    Last Post: 21st March 2006, 00:54

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.