Results 1 to 3 of 3

Thread: QDockWidget move problem when using custom title widget

  1. #1
    Join Date
    Mar 2009
    Posts
    5
    Thanked 1 Time in 1 Post

    Default QDockWidget move problem when using custom title widget

    Hi,
    I want to create a dock widget with a custom title widget. That custom title widget has my own icons (maximize, minimize, close etc). A snapshot of the dock widget is attached.

    Source code is simply like that:

    Qt Code:
    1. QDockWidget *dock = new QDockWidget("name", parent);
    2. MyDockTitle * titleWidget = new MyDockTitle(dock);
    3. dock->setTitleBarWidget(titleWidget);
    To copy to clipboard, switch view to plain text mode 

    When I run the program, dock widget is shown appropriately but unfortunately I can not move the dock widget (it is in floating state). What can be the problem?

    P.S. When I dont use custom title widget, I can move dock widget.

    Thanks...
    Attached Images Attached Images

  2. #2
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QDockWidget move problem when using custom title widget

    From the docs:
    Mouse events that are not explicitly handled by the title bar widget must be ignored by calling QMouseEvent::ignore(). These events then propagate to the QDockWidget parent, which handles them in the usual manner, moving when the title bar is dragged, docking and undocking when it is double-clicked, etc.

  3. #3
    Join Date
    Mar 2009
    Posts
    5
    Thanked 1 Time in 1 Post

    Default Re: QDockWidget move problem when using custom title widget

    Thank you very much for your answer. Can you explain how can I call
    Qt Code:
    1. QMouseEvent::ignore()
    To copy to clipboard, switch view to plain text mode 
    by giving a piece of code.
    I tried the following but the mouseMoveEvent never reaches to parent widget so I can not move the widget.

    Qt Code:
    1. void MyDockTitle::mouseMoveEvent ( QMouseEvent * event )
    2. {
    3. qDebug()<< "mouseMoveEvent";
    4. event->ignore();
    5. }
    To copy to clipboard, switch view to plain text mode 

    Thanks in advance...

Similar Threads

  1. QDockWidget/Central Widget Problem
    By Lemming in forum Qt Programming
    Replies: 7
    Last Post: 3rd April 2016, 09:52
  2. QDockWidget-title
    By moowy in forum Qt Programming
    Replies: 18
    Last Post: 23rd April 2014, 20:13
  3. how to hide the title bar when a QDockWidget is docked?
    By oscar721 in forum Qt Programming
    Replies: 5
    Last Post: 23rd January 2014, 20:16
  4. Combined Title and Tab for QDockWidget
    By chaoticbob in forum Qt Programming
    Replies: 0
    Last Post: 25th May 2010, 19:16
  5. contextmenu in QDockWidget title
    By klipko in forum Newbie
    Replies: 4
    Last Post: 7th March 2008, 22:32

Tags for this Thread

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.