Results 1 to 2 of 2

Thread: Top level widgets shown while moving dockwidgets

  1. #1
    Join Date
    Feb 2011
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default Top level widgets shown while moving dockwidgets

    Hi all,
    I wonder how I can show 4 static widgets (arrows) that are top level in the MainWindow, while I'm moving QDockWidgets.

    I've tried Qt::Popup flag, but that makes the last added widget to receive all the events and I miss the correct dockwidget movement. I can make myCustomControl to work (it shows information about dockPositions), but the default movement of the dockwidget drag doesn't work.

    Any idea? Should I use another flag, or how to send the events to my MainWindow? This is my eventFilter (it works when widgets don't use the Qt::Popup flag):

    Qt Code:
    1. bool MainWindow::eventFilter(QObject *obj, QEvent *event)
    2. {
    3. if(obj->inherits("QDockWidget"))
    4. {
    5. if(event->type() == QEvent::Paint)
    6. {
    7. return QMainWindow::eventFilter(obj, event);
    8. }
    9.  
    10. qDebug() << "QDockWidget event received";
    11. QDockWidget *dockwidget = static_cast<QDockWidget*>(obj);
    12. dockwidget->setAllowedAreas(Qt::NoDockWidgetArea); /*This avoids drawing the blue target gap*/
    13.  
    14. if (event->type() == QEvent::MouseButtonPress)
    15. {
    16. qDebug () << "Mouse Button Press in dockwidget received";
    17. mousePressed = true;
    18. dockDragging = dockwidget;
    19. QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
    20. dragStartPosition = mouseEvent->pos();
    21. return QMainWindow::eventFilter(obj, event);
    22. }
    23. if (event->type() == QEvent::MouseMove)
    24. {
    25. qDebug () << "Mouse Move in dockwidget received";
    26. QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
    27. if(mousePressed && (mouseEvent->pos() - dragStartPosition).manhattanLength() > QApplication::startDragDistance())
    28. {
    29. trackDockWidgetsPositions(Qt::AllDockWidgetAreas);
    30. if(arrows->areHidden())
    31. {
    32. showMainArrows();
    33. qDebug () << "Arrows shown" ;
    34. }
    35. myCustomControl();
    36. }
    37.  
    38. return QMainWindow::eventFilter(obj, event);
    39. }
    40. if (event->type() == QEvent::MouseButtonRelease)
    41. {
    42. qDebug () << "Mouse Button Release in dockwidget received";
    43. hideMainArrows();
    44. mousePressed = false;
    45. QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
    46. positionControl(mouseEvent->globalPos(), dockwidget);
    47. if(dockwidget->isHidden())
    48. {
    49. dockwidget->show();
    50. }
    51. return QMainWindow::eventFilter(obj, event);
    52. }
    53.  
    54. }
    55.  
    56. if(obj->inherits("ControlArrow"))
    57. {
    58. qDebug() << "event" << event->type();
    59. if(event->type() == QEvent::Paint)
    60. {
    61. return QMainWindow::eventFilter(obj, event);
    62. }
    63. else if(event->type() == QEvent::MouseMove || event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonRelease)
    64. {
    65. QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
    66. return DragDropControl::eventFilter(dockDragging, event);
    67. }
    68. }
    69. return QMainWindow::eventFilter(obj, event);
    70. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Feb 2011
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Top level widgets shown while moving dockwidgets

    Qt::ToolTip

Similar Threads

  1. Managing Widgets that aren't on the top level
    By prusikknot in forum Qt Programming
    Replies: 0
    Last Post: 19th April 2010, 16:51
  2. Avoid moving widgets
    By desch in forum Qt Programming
    Replies: 5
    Last Post: 9th April 2009, 06:27
  3. Mac OS X Top-Level Transparent Widgets
    By tinsuke in forum Qt Programming
    Replies: 0
    Last Post: 17th October 2008, 16:01
  4. Replies: 0
    Last Post: 1st October 2008, 16:21
  5. aspect ratio of top-level widgets
    By urbangipsy in forum Qt Programming
    Replies: 3
    Last Post: 16th January 2007, 21:49

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.