开发者

QDockWidget move problem when using custom title widget

开发者 https://www.devze.com 2023-01-15 12:50 出处:网络
I want to create a dock widget with a custom title widget. That custom title widget has my own icons (maximize, minimize, close etc).

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 ca开发者_开发百科n be the problem?

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

Thanks...


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号