Results 1 to 9 of 9

Thread: QDockWidget can't hear dragMoveEvent when undocked. Why?

  1. #1
    Join Date
    May 2006
    Location
    Stockholm, Sweden
    Posts
    81
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default QDockWidget can't hear dragMoveEvent when undocked. Why?

    Hi!
    I have a QMainWindow that has a QDockWidget that shows a tree view. The tree view is supposed to let the user to rearange the tree by dragNdrop. This works fine when the program is started with the QDockWidget is attached to the QMainWindow. But when I have dettached the QDockWidget it only hears the startDrag(). But the dragMoveEvent is not triggered. If I reattach the QDockWidget to the QMainWindow again, it doesn't work either. It only works when the program is started with the QDockWidget attached to the QMainWindow.

    I can't figure out why this is happening. Is there someone that has an idea?

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

    Default Re: QDockWidget can't hear dragMoveEvent when undocked. Why?

    Which widget should handle the drag? The dock widget or the tree view?

  3. #3
    Join Date
    May 2006
    Location
    Stockholm, Sweden
    Posts
    81
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: QDockWidget can't hear dragMoveEvent when undocked. Why?

    The QDockWidget is only holding the treewidget. The mouse handling should be handled by the treewidget. I have tried to grab the mouse. But this did not work.

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

    Default Re: QDockWidget can't hear dragMoveEvent when undocked. Why?

    Grab the mouse? What for? So if the problem concerns the tree drag, why do you ask about the dock widget? And is it a tree view or a tree widget?

  5. #5
    Join Date
    May 2006
    Location
    Stockholm, Sweden
    Posts
    81
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: QDockWidget can't hear dragMoveEvent when undocked. Why?

    Because I think that the problem is created by the QDockWidget. Everything worked when I used a QDialog. But I want to use a QDockWidget. And it works if the QDockWidget is attached to the QMainWindow and stop working when I have dettached it. That is why I am askint about the QDockWidget. Because I suppose that it doesn't receive the propper mouse actions it need to fullfill the dragndrop. That is why I thought that I maybe could try to grab the mouse. If I knew where the problem where, I wouldn't write this question... so the only thing I can do is to describe the problem.

    It is a TreeView.

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

    Default Re: QDockWidget can't hear dragMoveEvent when undocked. Why?

    Can we see a minimal compilable example reproducing the problem? And which exactly release of Qt do you use?

  7. #7
    Join Date
    May 2006
    Location
    Stockholm, Sweden
    Posts
    81
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: QDockWidget can't hear dragMoveEvent when undocked. Why?

    Sorry, the part of the program is too large. It would take me too long time prepare an example. I just wondered if it was a normal behaviour of QDockWidgets. I suppose it isn't.

    I am using Qt-4.2.1

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

    Default Re: QDockWidget can't hear dragMoveEvent when undocked. Why?

    Quote Originally Posted by pir View Post
    It would take me too long time prepare an example.
    An example would help you make sure the error is not in your code.
    I just wondered if it was a normal behaviour of QDockWidgets. I suppose it isn't.
    It shouldn't be, but nobody says QDockWidget has to be responsible.

    I couldn't find any entry in a task-tracker that'd seem related to the behaviour you experience.

    Edit: I have written an example myself and it seems to work fine, so probably you have some error in your code.

    Qt Code:
    1. #include <QMainWindow>
    2. #include <QDockWidget>
    3. #include <QApplication>
    4. #include <QTreeWidget>
    5.  
    6.  
    7. int main(int argc, char **argv){
    8. QApplication app(argc, argv);
    9. QDockWidget *dock = new QDockWidget(&mw);
    10. QTreeWidget *tree = new QTreeWidget;
    11. for(int i=0;i<5;i++)
    12. (new QTreeWidgetItem(tree))->setText(0,QString::number(i+1));
    13. tree->setDragDropMode(QAbstractItemView::DragDrop);
    14. tree->setDragEnabled(true);
    15. tree->setAcceptDrops(true);
    16. dock->setWidget(tree);
    17. mw.addDockWidget(Qt::LeftDockWidgetArea, dock);
    18. mw.show();
    19. return app.exec();
    20. }
    To copy to clipboard, switch view to plain text mode 

    If I float the dock widget I can still drag and drop items in the tree. Qt version 4.2.2.
    Last edited by wysota; 3rd February 2007 at 23:17.

  9. #9
    Join Date
    May 2006
    Location
    Stockholm, Sweden
    Posts
    81
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: QDockWidget can't hear dragMoveEvent when undocked. Why?

    I installed Qt-4.2.2 and now it works fine. Didn't need to change anything.

    But thanks anyway

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.