Page 2 of 2 FirstFirst 12
Results 21 to 26 of 26

Thread: [SOLVED] Detachable QDockWidget tabs

  1. #21
    Join Date
    Oct 2014
    Posts
    81
    Thanks
    20
    Thanked 9 Times in 9 Posts
    Qt products
    Qt5
    Platforms
    Windows
    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.

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

    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 

  3. #23
    Join Date
    Oct 2014
    Posts
    81
    Thanks
    20
    Thanked 9 Times in 9 Posts
    Qt products
    Qt5
    Platforms
    Windows
    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.

  4. #24
    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

  5. #25
    Join Date
    Oct 2014
    Posts
    81
    Thanks
    20
    Thanked 9 Times in 9 Posts
    Qt products
    Qt5
    Platforms
    Windows
    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.

  6. #26
    Join Date
    Sep 2015
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: [SOLVED] Detachable QDockWidget tabs

    I have tried implement sendOSMouseEvent() for UBUNTU 14 as below, But it DO NOT run correctly, any one please help me...

    Qt Code:
    1. void sendOSMouseEvent( SynthMouseEvent eventType, int x, int y )
    2. {
    3. // Create and setting up the event
    4. Display *display = XOpenDisplay(NULL);
    5.  
    6. // Create and setting up the event
    7. XEvent event;
    8. memset (&event, 0, sizeof (event));
    9. event.xbutton.button = Button1;
    10. event.xbutton.x = x;
    11. event.xbutton.y = y;
    12. event.xbutton.same_screen = True;
    13. event.xbutton.subwindow = DefaultRootWindow (display);
    14. while (event.xbutton.subwindow)
    15. {
    16. event.xbutton.window = event.xbutton.subwindow;
    17. XQueryPointer (display, event.xbutton.window,
    18. &event.xbutton.root, &event.xbutton.subwindow,
    19. &event.xbutton.x_root, &event.xbutton.y_root,
    20. &event.xbutton.x, &event.xbutton.y,
    21. &event.xbutton.state);
    22. }
    23.  
    24. switch ( eventType )
    25. {
    26. case MousePress:
    27. // Send a Windows left mouse button press event using SendInput.
    28. event.type = ButtonPress;
    29. if (XSendEvent (display, PointerWindow, True, ButtonPressMask, &event) == 0)
    30. qDebug("Error to send the event!");
    31. XFlush (display);
    32. break;
    33.  
    34. case MouseRelease:
    35. // Send a Windows left mouse button release event using SendInput.
    36. event.type = ButtonRelease;
    37. if (XSendEvent (display, PointerWindow, True, ButtonReleaseMask, &event) == 0)
    38. qDebug("Error to send the event!");
    39. XFlush (display);
    40. break;
    41.  
    42. case MouseMove:
    43. // Not used right now.
    44. break;
    45. }
    46. }
    To copy to clipboard, switch view to plain text mode 

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.