tags:

views:

47

answers:

1

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).

Source code is simply like that:

  QDockWidget *dock = new QDockWidget("name", parent);
  MyDockTitle * titleWidget = new MyDockTitle(dock);
  dock->setTitleBarWidget(titleWidget);

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...

+2  A: 

The Qt documentation of setTitleBarWidget() says:

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.

So I guess you need to add some QMouseEvent::ignore() calls to your MyDockTitle class.

Roku