Results 1 to 2 of 2

Thread: drag and drop

  1. #1
    Join Date
    Mar 2006
    Posts
    29
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default drag and drop

    Hi All

    I am vijay using VS 2005 with Qt 4.1. I do drag and drop operations from one label pixmap to another label . In My source code

    i have written this statement.

    void CMyClass : dropEvent(QDropEvent *event)
    {
    QLabel *child=static_cast<QLabel*>(childAt(event->pos()));
    }
    childAt statement returns the corresponding widget located at event->pos( when we release the mouse). This works fine when we release the mouse on label box. but if we release the mouse on text box or frame the program get crossing. I want to solve this problem. If we release the mouse on other widgets except label, it should ignore

    Can you help me.

    thanks and regards
    vijay

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: drag and drop

    Instead of the dialog/window/whatever widget, you could implement the drag and drop events in all individual labels (either by subclassing or by event filters).
    If you don't want to do that, you could also use dynamic cast to check whether the underlying widget is of wanted type. This is a bit uglier than the first solution, but needs less effort with the code you already have.
    J-P Nurmi

Similar Threads

  1. Drag and Drop QTableWidget in UI file.
    By tpf80 in forum Qt Programming
    Replies: 3
    Last Post: 20th January 2009, 23:02
  2. drag and drop QToolButton in QToolBar
    By NBilal in forum Qt Programming
    Replies: 1
    Last Post: 28th December 2008, 20:11
  3. Change cursor & status during Drag & Drop
    By ronlongo in forum Qt Programming
    Replies: 0
    Last Post: 1st December 2008, 16:56
  4. Drag & Drop when parent and childs accept drops?
    By gri in forum Qt Programming
    Replies: 0
    Last Post: 17th October 2008, 09:00
  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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.