# Hide mainWindow title bar

**URL:** <https://discourse.slicer.org/t/hide-mainwindow-title-bar/35666>\
**Category:** Development\
**Created:** [April 23, 2024, 5:24am UTC](https://discourse.slicer.org/t/hide-mainwindow-title-bar/35666 "2024-04-23T05:24:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![park](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/park/32/5717_2.png) [@park](https://discourse.slicer.org/u/park)\
**Post date:** [April 23, 2024, 5:24am UTC](https://discourse.slicer.org/t/hide-mainwindow-title-bar/35666/1 "2024-04-23T05:24:38Z")

</div>

Hi all.

I would like to hide the title bar of the mainWindow (as shown in the figure below). Thus, I have tried the code below, But the mainWindow itself closed.  
Could I get solution about this ?

```auto
flags = qt.Qt.FramelessWindowHint

main = slicer.util.mainWindow()
main.setWindowFlags(flags)

```

![titlebar](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/5/753cd208187d66b69194b66628855a0dcc5b1cfc.png)

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [April 23, 2024, 12:18pm UTC](https://discourse.slicer.org/t/hide-mainwindow-title-bar/35666/2 "2024-04-23T12:18:26Z")

</div>

You might have to set the flag before the window is created.

Since this is basically just Qt, you could experiment with Qt examples and then port what you learn to the Slicer code.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [April 23, 2024, 1:54pm UTC](https://discourse.slicer.org/t/hide-mainwindow-title-bar/35666/3 "2024-04-23T13:54:41Z")

</div>

You can find the solution on the Qt forum:

> **[FramelessWindowHint fails at runtime on MainWindow](https://forum.qt.io/topic/60642/framelesswindowhint-fails-at-runtime-on-mainwindow/5)**
>
> When I execute setWindowFlags(Qt::FramelessWindowHint) before the main window is shown this works, but if I try to execute after the main window is shown the window disappears from the screen and the task manager but is still running. I have to kill...

```auto
main = slicer.util.mainWindow()
main.hide()
main.setWindowFlags(qt.Qt.FramelessWindowHint)
main.show()

```

---

<div class="post-metadata">

**Author:** ![park](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/park/32/5717_2.png) [@park](https://discourse.slicer.org/u/park)\
**Post date:** [April 23, 2024, 3:58pm UTC](https://discourse.slicer.org/t/hide-mainwindow-title-bar/35666/4 "2024-04-23T15:58:26Z")

</div>

Thanks @lassoan @pieper .  
This is exactly what I wanted !
