Results 1 to 20 of 26

Thread: [SOLVED] Detachable QDockWidget tabs

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2014
    Posts
    5
    Qt products
    Qt5
    Platforms
    MacOS X
    Thanked 1 Time in 1 Post

    Default Re: [SOLVED] Detachable QDockWidget tabs

    I tried global coordinates for only MousePress and both MouseRelease and MousePress, but both cases didn't work.
    I got this warning message and stacktrace (it's too long to post here, so I attached the full stack trace).

    Qt Code:
    1. QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton)
    2. QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton)
    3. QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton)
    4. The program has unexpectedly finished.
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. Exception Type: EXC_BAD_ACCESS (SIGSEGV)
    2. Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000008
    3.  
    4. Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
    5. 0 org.qt-project.QtWidgets 0x000000010bb40f47 QDockWidget::setFloating(bool) + 23
    6. 1 com.example.DetachDockExample 0x000000010b9dd624 DetachableDockManager::eventFilter(QObject*, QEvent*) + 484 (DetachableDockManager.cpp:418)
    7. 2 org.qt-project.QtCore 0x000000010c8a72f9 QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) + 217
    8. 3 org.qt-project.QtWidgets 0x000000010ba2adab QApplicationPrivate::notify_helper(QObject*, QEvent*) + 235
    9. 4 org.qt-project.QtWidgets 0x000000010ba2e65f QApplication::notify(QObject*, QEvent*) + 9551
    10. 5 org.qt-project.QtCore 0x000000010c8a6fb3 QCoreApplication::notifyInternal(QObject*, QEvent*) + 115
    11. 6 org.qt-project.QtWidgets 0x000000010ba2b73b QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) + 987
    12. 7 org.qt-project.QtWidgets 0x000000010ba85161 QWidgetWindow::handleMouseEvent(QMouseEvent*) + 1217
    13. 8 org.qt-project.QtWidgets 0x000000010ba8439f QWidgetWindow::event(QEvent*) + 111
    14. 9 org.qt-project.QtWidgets 0x000000010ba2adbb QApplicationPrivate::notify_helper(QObject*, QEvent*) + 251
    15. 10 org.qt-project.QtWidgets 0x000000010ba2e110 QApplication::notify(QObject*, QEvent*) + 8192
    16. 11 org.qt-project.QtCore 0x000000010c8a6fb3 QCoreApplication::notifyInternal(QObject*, QEvent*) + 115
    17. 12 org.qt-project.QtGui 0x000000010c0e2d3d QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) + 2189
    18. 13 org.qt-project.QtGui 0x000000010c0e2671 QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) + 449
    19. 14 org.qt-project.QtGui 0x000000010c0e1bd3 QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) + 131
    20. 15 org.qt-project.QtGui 0x000000010c0cf51a QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 346
    21. 16 libqcocoa.dylib 0x000000010ecd36ff QCocoaEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 1631
    22. 17 com.example.DetachDockExample 0x000000010b9dd64f DetachableDockManager::eventFilter(QObject*, QEvent*) + 527 (DetachableDockManager.cpp:422)
    23. 18 org.qt-project.QtCore 0x000000010c8a72f9 QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) + 217
    24. 19 org.qt-project.QtWidgets 0x000000010ba2adab QApplicationPrivate::notify_helper(QObject*, QEvent*) + 235
    25. 20 org.qt-project.QtWidgets 0x000000010ba2e65f QApplication::notify(QObject*, QEvent*) + 9551
    26. 21 org.qt-project.QtCore 0x000000010c8a6fb3 QCoreApplication::notifyInternal(QObject*, QEvent*) + 115
    27. 22 org.qt-project.QtWidgets 0x000000010ba2b73b QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) + 987
    28. 23 org.qt-project.QtWidgets 0x000000010ba85161 QWidgetWindow::handleMouseEvent(QMouseEvent*) + 1217
    29. 24 org.qt-project.QtWidgets 0x000000010ba8439f QWidgetWindow::event(QEvent*) + 111
    30. 25 org.qt-project.QtWidgets 0x000000010ba2adbb QApplicationPrivate::notify_helper(QObject*, QEvent*) + 251
    31. 26 org.qt-project.QtWidgets 0x000000010ba2e110 QApplication::notify(QObject*, QEvent*) + 8192
    32. 27 org.qt-project.QtCore 0x000000010c8a6fb3 QCoreApplication::notifyInternal(QObject*, QEvent*) + 115
    33. 28 org.qt-project.QtGui 0x000000010c0e2d3d QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) + 2189
    34. 29 org.qt-project.QtGui 0x000000010c0e2671 QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) + 449
    35. 30 org.qt-project.QtGui 0x000000010c0e1bd3 QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) + 131
    36. 31 org.qt-project.QtGui 0x000000010c0cf51a QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 346
    37. 32 org.qt-project.QtGui 0x000000010c0cd611 QWindowSystemInterface::flushWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 673
    38. 33 libqcocoa.dylib 0x000000010ecc9341 -[QNSView updateGeometry] + 545
    39. 34 com.apple.CoreFoundation 0x00007fff8c346e0c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
    40. 35 com.apple.CoreFoundation 0x00007fff8c23a82d _CFXNotificationPost + 2893
    41. 36 com.apple.Foundation 0x00007fff91d15e4a -[NSNotificationCenter postNotificationName:object:userInfo:] + 68
    42. 37 com.apple.AppKit 0x00007fff8b0f6f81 -[NSWindow _setFrameCommon:display:stashSize:] + 1958
    43. 38 com.apple.AppKit 0x00007fff8b276492 __25-[NSWindow setStyleMask:]_block_invoke + 878
    44. 39 com.apple.AppKit 0x00007fff8b1001e8 NSPerformWithScreenUpdatesDisabled + 65
    45. 40 com.apple.AppKit 0x00007fff8b2760e5 -[NSWindow setStyleMask:] + 172
    46. 41 libqcocoa.dylib 0x000000010ecc4350 QCocoaWindow::setWindowFlags(QFlags<Qt::WindowType>) + 96
    47. 42 org.qt-project.QtGui 0x000000010c0ecfc3 QWindow::setFlags(QFlags<Qt::WindowType>) + 35
    48. 43 org.qt-project.QtWidgets 0x000000010ba582f9 QWidgetPrivate::create_sys(unsigned long long, bool, bool) + 649
    49. 44 org.qt-project.QtWidgets 0x000000010ba57119 QWidget::create(unsigned long long, bool, bool) + 425
    50. 45 org.qt-project.QtWidgets 0x000000010ba6cf14 QWidgetPrivate::setParent_sys(QWidget*, QFlags<Qt::WindowType>) + 1668
    51. 46 org.qt-project.QtWidgets 0x000000010ba576f8 QWidget::setParent(QWidget*, QFlags<Qt::WindowType>) + 952
    52. 47 org.qt-project.QtWidgets 0x000000010ba6c7be QWidgetPrivate::setWindowFlags(QFlags<Qt::WindowType>) + 158
    53. 48 org.qt-project.QtWidgets 0x000000010bb42263 QDockWidgetPrivate::setWindowState(bool, bool, QRect const&) + 307
    54. 49 org.qt-project.QtWidgets 0x000000010bb433b3 QDockWidget::setTitleBarWidget(QWidget*) + 115
    55. 50 com.example.DetachDockExample 0x000000010b9dc3dc DetachableDock::changeTitleBar(bool) + 60 (DetachableDock.cpp:44)
    56. 51 com.example.DetachDockExample 0x000000010b9dd08b DetachableDockManager::topLevelUpdateDock(DetachableDock*, DetachableDockManager::TopLevelChange) + 123 (DetachableDockManager.cpp:311)
    57. 52 com.example.DetachDockExample 0x000000010b9dcfb6 DetachableDockManager::onDockTopLevelChanged(bool) + 1302 (DetachableDockManager.cpp:179)
    58. 53 com.example.DetachDockExample 0x000000010b9e0992 DetachableDockManager::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) + 114 (moc_DetachableDockManager.cpp:83)
    59. 54 org.qt-project.QtCore 0x000000010c8d99db QMetaObject::activate(QObject*, int, int, void**) + 2987
    60. 55 org.qt-project.QtWidgets 0x000000010bb422e8 QDockWidgetPrivate::setWindowState(bool, bool, QRect const&) + 440
    61. 56 org.qt-project.QtWidgets 0x000000010bb41001 QDockWidget::setFloating(bool) + 209
    62. 57 com.example.DetachDockExample 0x000000010b9dd624 DetachableDockManager::eventFilter(QObject*, QEvent*) + 484 (DetachableDockManager.cpp:418)
    63. 58 org.qt-project.QtCore 0x000000010c8a72f9 QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) + 217
    64. 59 org.qt-project.QtWidgets 0x000000010ba2adab QApplicationPrivate::notify_helper(QObject*, QEvent*) + 235
    65. 60 org.qt-project.QtWidgets 0x000000010ba2e65f QApplication::notify(QObject*, QEvent*) + 9551
    66. 61 org.qt-project.QtCore 0x000000010c8a6fb3 QCoreApplication::notifyInternal(QObject*, QEvent*) + 115
    67. 62 org.qt-project.QtWidgets 0x000000010ba2b73b QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) + 987
    68. 63 org.qt-project.QtWidgets 0x000000010ba85161 QWidgetWindow::handleMouseEvent(QMouseEvent*) + 1217
    69. 64 org.qt-project.QtWidgets 0x000000010ba8439f QWidgetWindow::event(QEvent*) + 111
    70. 65 org.qt-project.QtWidgets 0x000000010ba2adbb QApplicationPrivate::notify_helper(QObject*, QEvent*) + 251
    71. 66 org.qt-project.QtWidgets 0x000000010ba2e110 QApplication::notify(QObject*, QEvent*) + 8192
    72. 67 org.qt-project.QtCore 0x000000010c8a6fb3 QCoreApplication::notifyInternal(QObject*, QEvent*) + 115
    73. 68 org.qt-project.QtGui 0x000000010c0e2d3d QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) + 2189
    74. 69 org.qt-project.QtGui 0x000000010c0e2671 QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) + 449
    75.  
    76. ... continued (Please check the attached text to see the full stack trace)
    To copy to clipboard, switch view to plain text mode 
    Attached Files Attached Files

  2. The following user says thank you to shinichy for this useful post:

    Kryzon (31st January 2015)

  3. #2
    Join Date
    Oct 2014
    Posts
    81
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    20
    Thanked 9 Times in 9 Posts
    Wiki edits
    7

    Default Re: [SOLVED] Detachable QDockWidget tabs

    Do you know what code line caused the crash?
    I would keep the global coordinates, since it's the correct way. I don't think they're influencing the warning or the crash.

    I'm not sure how to fix this on OS X since I don't have a system to test it on. It must have to do with the order or the events.
    The warning is created here:
    https://qt.gitorious.org/qt/qtbase/s...nsview.mm#L765

    It probably has to do with us sending a synthetic mouse release event while the button is down, even if it's just for a quick moment, and then moving the cursor with setPos(), which causes a mouse drag event with an invalid button.

    I'll try to think of a different event order. If I'm not mistaken the crash happens in that block that detaches the dock, inside the event filter?

  4. #3
    Join Date
    Nov 2014
    Posts
    5
    Qt products
    Qt5
    Platforms
    MacOS X
    Thanked 1 Time in 1 Post

    Default Re: [SOLVED] Detachable QDockWidget tabs

    The crash happens below line. I can't step into further because I can't attach Qt source code in my Qt Creator.

    Qt Code:
    1. detachingDock->setFloating( true );
    To copy to clipboard, switch view to plain text mode 

    I added debug messages around that line, then I got the following output.

    Qt Code:
    1. qDebug("before setFloating");
    2. detachingDock->setFloating( true );
    3. qDebug("after setFloating");
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. Starting /Users/shinichi/Code/build-DetachDockExample-Desktop_Qt_5_4_0_clang_64bit-Debug/DetachDockExample.app/Contents/MacOS/DetachDockExample...
    2. before setFloating
    3. after setFloating
    4. QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton)
    5. QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton)
    6. before setFloating
    7. before setFloating
    8. after setFloating
    9. QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton)
    10. before setFloating
    11. before setFloating
    12. after setFloating
    13. QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton)
    14. before setFloating
    15. The program has unexpectedly finished.
    To copy to clipboard, switch view to plain text mode 

  5. #4
    Join Date
    Oct 2014
    Posts
    81
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    20
    Thanked 9 Times in 9 Posts
    Wiki edits
    7

    Default Re: [SOLVED] Detachable QDockWidget tabs

    Thank you for the information.
    I've changed the event order when the dock is detached. It still works under Windows XP, so hopefully it works now on OS X.

    I noticed a title bar bug when undocking on a certain occasion, but I've been unable to reproduce it. So there may be improvements left to be made to this system.

    The new event order in DetachableDockManager::eventFilter is as below:

    Qt Code:
    1. if ( ( mouseEvent->pos() - clickPos ).manhattanLength() > QApplication::startDragDistance() )
    2. {
    3. // The user wants to detach a dock tab.
    4.  
    5. if ( pressedTabIndex != -1 )
    6. {
    7. consumed = true;
    8.  
    9. // *** Trying a different event order to avoid a crash on OS X.
    10.  
    11. QApplication::processEvents(); // Process all pending events to start with a clean queue.
    12.  
    13. /* It is essential to release the mouse button that is currently holding on to the tab bar
    14. so that the dock widget can be dragged. This needs to be done with an OS level event. */
    15.  
    16. #ifdef Q_OS_WIN
    17.  
    18. // On Windows we use relative mouse coordinates.
    19.  
    20. sendOSMouseEvent( SynthMouseEvent::MouseRelease, 0, 0 );
    21.  
    22. #endif
    23.  
    24. #ifdef Q_OS_OSX
    25.  
    26. // On OS X we use absolute mouse coordinates.
    27.  
    28. QPoint cursorPos = QCursor::pos();
    29. sendOSMouseEvent( SynthMouseEvent::MouseRelease, cursorPos.x(), cursorPos.y() );
    30.  
    31. #endif
    32.  
    33. /* Detach the dock that the user wants.
    34. This restores the default title bar from the top level change, and also
    35. restores the title bar of its tab bar neighbour if they were in a two-page tab bar. */
    36.  
    37. DetachableDock* detachingDock = dockFromTab( pressedTabBar, pressedTabIndex );
    38. detachingDock->setFloating( true );
    39.  
    40. // Process events right after floating the dock to avoid an animation glitch.
    41.  
    42. QApplication::processEvents();
    43.  
    44. // Centre the dock title bar on the latest cursor position so the mouse press doesn't miss it.
    45.  
    46. detachingDock->centreTitle( QCursor::pos() );
    47.  
    48. // OPTIONAL. Process events again after centering the dock so it's redrawn immediately.
    49.  
    50. QApplication::processEvents();
    51.  
    52. // Synthesize a mouse press to grab the dock that is placed on the cursor, so it can be dragged.
    53.  
    54. #ifdef Q_OS_WIN
    55. sendOSMouseEvent( SynthMouseEvent::MousePress, 0, 0 );
    56. #endif
    57.  
    58. #ifdef Q_OS_OSX
    59. sendOSMouseEvent( SynthMouseEvent::MousePress, cursorPos.x(), cursorPos.y() );
    60. #endif
    61. QApplication::processEvents(); // Make sure that these events are processed right now to avoid surprises.
    62. }
    63. }
    To copy to clipboard, switch view to plain text mode 
    If it still doesn't work, try adding a 'QApplication::processEvents()' call right before the 'detachingDock->setFloating( true )' call.

    You can also download the full project with these modifications, as attached.
    Attached Files Attached Files

  6. #5
    Join Date
    Nov 2014
    Posts
    5
    Qt products
    Qt5
    Platforms
    MacOS X
    Thanked 1 Time in 1 Post

    Default Re: [SOLVED] Detachable QDockWidget tabs

    I tried your new project but it still doesn't work. Even with 'QApplication:rocessEvents()' call right before the 'detachingDock->setFloating( true )' call.
    Here's the output and the stack trace. Both seem same as before.

    Qt Code:
    1. QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton)
    2. QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton)
    3. QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton)
    4. QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton)
    5. QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton)
    6. QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton)
    7. The program has unexpectedly finished.
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
    2. 0 org.qt-project.QtWidgets 0x000000010e950f47 QDockWidget::setFloating(bool) + 23
    3. 1 com.example.DetachDockExample 0x000000010e7f16e0 DetachableDockManager::eventFilter(QObject*, QEvent*) + 528
    4. 2 org.qt-project.QtCore 0x000000010f6b62f9 QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) + 217
    5. 3 org.qt-project.QtWidgets 0x000000010e83adab QApplicationPrivate::notify_helper(QObject*, QEvent*) + 235
    6. 4 org.qt-project.QtWidgets 0x000000010e83e65f QApplication::notify(QObject*, QEvent*) + 9551
    7. 5 org.qt-project.QtCore 0x000000010f6b5fb3 QCoreApplication::notifyInternal(QObject*, QEvent*) + 115
    8. 6 org.qt-project.QtWidgets 0x000000010e83b73b QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) + 987
    9. 7 org.qt-project.QtWidgets 0x000000010e895161 QWidgetWindow::handleMouseEvent(QMouseEvent*) + 1217
    10. 8 org.qt-project.QtWidgets 0x000000010e89439f QWidgetWindow::event(QEvent*) + 111
    11. 9 org.qt-project.QtWidgets 0x000000010e83adbb QApplicationPrivate::notify_helper(QObject*, QEvent*) + 251
    12. 10 org.qt-project.QtWidgets 0x000000010e83e110 QApplication::notify(QObject*, QEvent*) + 8192
    13. 11 org.qt-project.QtCore 0x000000010f6b5fb3 QCoreApplication::notifyInternal(QObject*, QEvent*) + 115
    14. 12 org.qt-project.QtGui 0x000000010eeeed3d QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) + 2189
    15. 13 org.qt-project.QtGui 0x000000010eeee671 QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) + 449
    16. 14 org.qt-project.QtGui 0x000000010eeedbd3 QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) + 131
    17. 15 org.qt-project.QtGui 0x000000010eedb51a QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 346
    18. 16 libqcocoa.dylib 0x0000000111adb6ff QCocoaEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 1631
    19. 17 com.example.DetachDockExample 0x000000010e7f166c DetachableDockManager::eventFilter(QObject*, QEvent*) + 412
    20. 18 org.qt-project.QtCore 0x000000010f6b62f9 QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) + 217
    21. 19 org.qt-project.QtWidgets 0x000000010e83adab QApplicationPrivate::notify_helper(QObject*, QEvent*) + 235
    22. 20 org.qt-project.QtWidgets 0x000000010e83e65f QApplication::notify(QObject*, QEvent*) + 9551
    23. 21 org.qt-project.QtCore 0x000000010f6b5fb3 QCoreApplication::notifyInternal(QObject*, QEvent*) + 115
    24. 22 org.qt-project.QtWidgets 0x000000010e83b73b QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) + 987
    25. 23 org.qt-project.QtWidgets 0x000000010e895161 QWidgetWindow::handleMouseEvent(QMouseEvent*) + 1217
    26. 24 org.qt-project.QtWidgets 0x000000010e89439f QWidgetWindow::event(QEvent*) + 111
    27. 25 org.qt-project.QtWidgets 0x000000010e83adbb QApplicationPrivate::notify_helper(QObject*, QEvent*) + 251
    28. 26 org.qt-project.QtWidgets 0x000000010e83e110 QApplication::notify(QObject*, QEvent*) + 8192
    29. 27 org.qt-project.QtCore 0x000000010f6b5fb3 QCoreApplication::notifyInternal(QObject*, QEvent*) + 115
    30. 28 org.qt-project.QtGui 0x000000010eeeed3d QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) + 2189
    31. 29 org.qt-project.QtGui 0x000000010eeee671 QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) + 449
    32. 30 org.qt-project.QtGui 0x000000010eeedbd3 QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) + 131
    33. 31 org.qt-project.QtGui 0x000000010eedb51a QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 346
    34. 32 libqcocoa.dylib 0x0000000111adb6ff QCocoaEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 1631
    35. 33 com.example.DetachDockExample 0x000000010e7f16fc DetachableDockManager::eventFilter(QObject*, QEvent*) + 556
    36. 34 org.qt-project.QtCore 0x000000010f6b62f9 QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) + 217
    37. 35 org.qt-project.QtWidgets 0x000000010e83adab QApplicationPrivate::notify_helper(QObject*, QEvent*) + 235
    38. 36 org.qt-project.QtWidgets 0x000000010e83e65f QApplication::notify(QObject*, QEvent*) + 9551
    39. 37 org.qt-project.QtCore 0x000000010f6b5fb3 QCoreApplication::notifyInternal(QObject*, QEvent*) + 115
    40. 38 org.qt-project.QtWidgets 0x000000010e83b73b QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) + 987
    41. 39 org.qt-project.QtWidgets 0x000000010e895161 QWidgetWindow::handleMouseEvent(QMouseEvent*) + 1217
    42. 40 org.qt-project.QtWidgets 0x000000010e89439f QWidgetWindow::event(QEvent*) + 111
    43. 41 org.qt-project.QtWidgets 0x000000010e83adbb QApplicationPrivate::notify_helper(QObject*, QEvent*) + 251
    44. 42 org.qt-project.QtWidgets 0x000000010e83e110 QApplication::notify(QObject*, QEvent*) + 8192
    45. 43 org.qt-project.QtCore 0x000000010f6b5fb3 QCoreApplication::notifyInternal(QObject*, QEvent*) + 115
    46. 44 org.qt-project.QtGui 0x000000010eeeed3d QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) + 2189
    47. 45 org.qt-project.QtGui 0x000000010eeee671 QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) + 449
    48. 46 org.qt-project.QtGui 0x000000010eeedbd3 QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) + 131
    49. 47 org.qt-project.QtGui 0x000000010eedb51a QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 346
    50. 48 libqcocoa.dylib 0x0000000111adb6ff QCocoaEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 1631
    51. 49 com.example.DetachDockExample 0x000000010e7f166c DetachableDockManager::eventFilter(QObject*, QEvent*) + 412
    52. 50 org.qt-project.QtCore 0x000000010f6b62f9 QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) + 217
    53. ...
    To copy to clipboard, switch view to plain text mode 

  7. #6
    Join Date
    Oct 2014
    Posts
    81
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    20
    Thanked 9 Times in 9 Posts
    Wiki edits
    7

    Default Re: [SOLVED] Detachable QDockWidget tabs

    From my observations on Windows, floating the dock only crashes the program if the tab bar still has the mouse focus when this happens. That is, the mouse release event for it isn't being recognised properly for some reason.

    I'll have to rely on someone's OS X expertise on this one, it's difficult to remotely debug.
    If you happen to find a solution by experimenting, please share it.

    Regards.

  8. #7
    Join Date
    Oct 2014
    Posts
    81
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    20
    Thanked 9 Times in 9 Posts
    Wiki edits
    7

    Default Re: [SOLVED] Detachable QDockWidget tabs

    Hello. Here's another try.
    I noticed that a synthesised mouse movement event is necessary to avoid having a miss-click when trying to grab the dock widget when the user is dragging the mouse really fast.
    In order to avoid that warning message on OS X, we can try to synthesize a mouse drag event with the left button set as "pressed." We can also test if the tab bar still has mouse focus after the synthesised mouse release, as a debugging measure.

    Modifications were made to the following files:

    - DetachableDockManager.cpp
    - SendOSMouseEvent.h
    - SendOSMouseEvent.mm
    - SyntheticMouseEvent.cpp

    The full project is attached.
    Attached Files Attached Files

  9. #8
    Join Date
    Oct 2014
    Posts
    81
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    20
    Thanked 9 Times in 9 Posts
    Wiki edits
    7

    Default Re: [SOLVED] Detachable QDockWidget tabs

    Continuing with the OS X tests, on that 1.2 project please replace the contents of the sendMouseMoveEvent function in the SendOSMouseEvent.mm file with the following.

    The modifications to SendOSMouseEvent.mm are the header of 'ApplicationServices' and the content of 'sendMouseMoveEvent.'

    Qt Code:
    1. #import <Cocoa/Cocoa.h>
    2. #import <CoreFoundation/CoreFoundation.h>
    3. #import <ApplicationServices/ApplicationServices.h>
    4. #import "sendOSMouseEvent.h"
    5.  
    6. void sendMousePressEvent(int x, int y) {
    7. CGPoint location = CGPointMake(x, y);
    8. CGEventRef mouseDown = CGEventCreateMouseEvent(NULL, kCGEventLeftMouseDown, location, kCGMouseButtonLeft);
    9. CGEventPost(kCGHIDEventTap, mouseDown);
    10. CFRelease(mouseDown);
    11. }
    12.  
    13. void sendMouseReleaseEvent(int x, int y) {
    14. CGPoint location = CGPointMake(x, y);
    15. CGEventRef mouseUp = CGEventCreateMouseEvent(NULL, kCGEventLeftMouseUp, location, kCGMouseButtonLeft);
    16. CGEventPost(kCGHIDEventTap, mouseUp);
    17. CFRelease(mouseUp);
    18. }
    19.  
    20. void sendMouseMoveEvent(int x, int y) {
    21. CGPoint location = CGPointMake(x, y);
    22. CGError ret = CGWarpMouseCursorPosition(location); // Move the mouse without generating a mouse move or drag event.
    23. if (ret == kCGErrorSuccess)
    24. CGAssociateMouseAndMouseCursorPosition(true); // If successful, re-associate mouse and cursor position to avoid a delay.
    25. }
    To copy to clipboard, switch view to plain text mode 
    It uses CGWarpMouseCursorPosition, which seems like a better solution that changes the mouse location without emitting events at all.
    What's left is to test this detachable dock system with a Wacom (or other brand) digitizer tablet.

  10. #9
    Join Date
    Nov 2014
    Posts
    5
    Qt products
    Qt5
    Platforms
    MacOS X
    Thanked 1 Time in 1 Post

    Default Re: [SOLVED] Detachable QDockWidget tabs

    It still doesn't work. Both the output and the stack trace seem same.
    Does it work on your Mac?

    Qt Code:
    1. QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton)
    2. QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton)
    3. QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton)
    4. QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton)
    5. The program has unexpectedly finished.
    To copy to clipboard, switch view to plain text mode 

  11. #10
    Join Date
    Oct 2014
    Posts
    81
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    20
    Thanked 9 Times in 9 Posts
    Wiki edits
    7

    Default Re: [SOLVED] Detachable QDockWidget tabs

    Hello.
    I don't have a Mac, so I was infering solutions based on what you reported.

    That Q_ASSERT_X in the eventFilter of project 1.2 (make sure you're using that, for information) and the CGWarpMouseCursorPosition from the modification above are all I can think of, for the moment. Thank you for testing.

  12. #11
    Join Date
    Jan 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: [SOLVED] Detachable QDockWidget tabs

    For me when I drag the tab, it seems to trigger the resize event for the floated dock widget.

    Anyone else have the same?

    Win7

  13. #12
    Join Date
    Oct 2014
    Posts
    81
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    20
    Thanked 9 Times in 9 Posts
    Wiki edits
    7

    Default Re: [SOLVED] Detachable QDockWidget tabs

    I wrote that under Windows XP and it was working there.
    Now I tested under Windows 8.1 and I'm having the same as you: the widget is entering resize mode once it's detached.

    The reason for that is the function "DetachableDock::centreTitle," it tries to compute the title bar height based on 'frameGeometry - geometry.' But they're both the same value, so the title bar is not being properly centered on the mouse cursor. According to the documentation it should be working, so we'll need to find a different way to estimate the title bar height.

    EDIT: Alright, here's the solution (thanks to this fellow Qt user)

    Inside "DetachableDock::centreTitle" in DetachableDock.cpp, add the following:

    Qt Code:
    1. #include <QStyle> // Add this include at the top, with the other includes.
    2.  
    3. [...]
    4.  
    5. void DetachableDock::centreTitle( QPoint here )
    6. {
    7. int centreTitleX = frameGeometry().width() / 2;
    8. int centreTitleY = style()->pixelMetric( QStyle::PM_TitleBarHeight, 0, this ) / 2; // Corrected line, it uses the standard pixel metric.
    9.  
    10. QPoint centreTitlePos = here - QPoint( centreTitleX, centreTitleY );
    11. move( centreTitlePos );
    12. }
    To copy to clipboard, switch view to plain text mode 

    While this fixes the detaching, the docking back doesn't seem to work anymore under Windows 8.1.
    The standard dock widgets example works fine, so it's this customisation that is broken.
    Last edited by Kryzon; 2nd July 2015 at 02:39.

Similar Threads

  1. QDockWidget + QTabBar, but tabs don't move
    By NIteLordz in forum Qt Programming
    Replies: 11
    Last Post: 22nd January 2015, 17:06
  2. Area for detachable QDialogs within QGridLayout
    By nicole.cpp in forum Newbie
    Replies: 3
    Last Post: 15th April 2014, 17:02
  3. Dragable QDockWidget tabs with no title bar?
    By nige in forum Qt Programming
    Replies: 1
    Last Post: 17th April 2013, 15:39
  4. Replies: 7
    Last Post: 8th April 2009, 08:42
  5. [SOLVED] QDockWidget::setVisible() doesn't work
    By Oleg in forum Qt Programming
    Replies: 2
    Last Post: 4th January 2008, 20:27

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.