How do I hide the window title bar from QDockWidget
-
I tired to move the dockWidgetContents up to make it looks better. I set the geometry of the starting y axis to negative, but it's not having any effect.
m_ui->dockWidgetContents ->setGeometry(0, -50, m_ui->dockWidgetContents ->width(), m_ui->dockWidgetContents ->height());
-
mrjj Lifetime Qt Championreplied to lansing on 5 Jul 2020, 18:15 last edited by mrjj 7 May 2020, 18:18
@lansing
Do you use a layout inside ?
that space on top kinda fits with a layout default content margins. -
mrjj Lifetime Qt Championreplied to lansing on 5 Jul 2020, 18:28 last edited by mrjj 7 May 2020, 18:28
Ok
so on the vertical layout, set its margins to zero and see. default its 12 pixels.
Im not sure if that is the case but it could explain the huge gap.
setContentsMargins(0,0,0,0); -
@lansing
Well when a widget is in a layout its not possible to move it.you could try to use
https://doc.qt.io/qt-5/qdockwidget.html#titleBarWidget
and then setFixedHeight(1);
and see if that changes anything. -
@lansing
Yes that was expected.
But did it accept smaller size ? -
mrjj Lifetime Qt Championreplied to lansing on 5 Jul 2020, 19:29 last edited by mrjj 7 May 2020, 19:30
@lansing
ah sorry my bad
Docs says
"Returns the custom title bar widget set on the QDockWidget, or nullptr if no custom title bar has been set."but we didnt anymore so its null. ok so not an option unless we do
m_ui->myDockWidget->setTitleBarWidget(new QWidget(m_ui->myDockWidget));But you are right. Its too hard to hit if smaller so guess we just have to leave it.
I just wonder where that space comes from as the examples don't have it.
-
@mrjj said in How do I hide the window title bar from QTabWidget:
I just wonder where that space comes from as the examples don't have it.
That must be the layout default margins...The OP mentioned using a vertical layout...
-
mrjj Lifetime Qt Championreplied to Bonnie on 5 Jul 2020, 19:33 last edited by mrjj 7 May 2020, 19:35
@Bonnie
Also my thought but we did try
setContentsMargins(0,0,0,0);
higher up.So maybe that space is really just the hidden titlebar, it just look bigger to me than the samples.
-
@mrjj said in How do I hide the window title bar from QTabWidget:
setContentsMargins(0,0,0,0);
I would guess that the OP call that on the widget, not the layout...
Ah...maybe not...
I'm not sure what's the current situation now. I thought the gap in the later picture would be that titlebar? -
@lansing
Ok so thats as far as we can come as you cannot move tabWidget more up. :) -
@Yunus
Hi
Sadly not. That flag removes the decorations. ( the frame) and those are used by the OS to resize.
It's possible to hand code it but it's hard work.
Often people use less code-intensive solution and allow resize from right, bottom corner only.
Using this class
https://doc.qt.io/qt-6/qsizegrip.html -
-
Hi
There is also
https://github.com/dfct/TrueFramelessWindow
which supports most features like resizing and dragging