0

I have a MainWindow.cpp class with multiple images displayed that emit a clicked() signal. Once clicked on I want to open a widget that's a fixed size inside MainWindow and I want this widget to be able to be dragged around as long as it stays inside the MainWindow class.

I was looking at example code to try and write this widget class, in particular the Qt MainWindow Example. However, once one of the dockwindows are dragged around the display the Operating System specific titlebar (which lets you maximize, minimize, and close the window) gets displayed. I do not want this titlebar to be displayed.

How would I go about creating this class of draggable widgets?

Cœur
  • 37,241
  • 25
  • 195
  • 267
DomX23
  • 867
  • 5
  • 13
  • 26

1 Answers1

0

Check setTitleBarWidget

Setting to a void widget will work:

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.

Edit: By request:

yourDockableWidget->setTitleBarWidget( new QWidget( yourDockableWidget ) );

In the example you are following, you could do it in constructor:

ColorSwatch::ColorSwatch(const QString &colorName, QWidget *parent, Qt::WindowFlags flags)
: QDockWidget(parent, flags)
{
/*...*/

setTitleBarWidget( new QWidget( this ) );

/*...*/
}

Now your widget wont have SO titlebar when undocked;

Tarod
  • 6,732
  • 5
  • 44
  • 50
trompa
  • 1,967
  • 1
  • 18
  • 26