检查setTitleBarWidget
设置为 void 小部件将起作用:
It is not possible to remove a title bar from a dock widget.
However, a similar effect can be achieved by setting a default constructed QWidget
as the title bar widget.
编辑:应要求:
yourDockableWidget->setTitleBarWidget( new QWidget( yourDockableWidget ) );
在您下面的示例中,您可以在构造函数中执行此操作:
ColorSwatch::ColorSwatch(const QString &colorName, QWidget *parent, Qt::WindowFlags flags)
: QDockWidget(parent, flags)
{
/*...*/
setTitleBarWidget( new QWidget( this ) );
/*...*/
}
现在您的小部件在取消停靠时不会有 SO 标题栏;