PDA

View Full Version : How to remove title bar of QWidget which is inside QTabWidget



duongtan_pfiev
2nd July 2019, 01:18
Hello,

I am developing an application in QT4 but I have a problem still not solving.
I hope someone can help me.

My app UI have a QTabwidget and inside tabwidget, there is a Qwidget. But when I open the app, the Title bar of QWidget display under the Title bar of mainwindow.
Currently, I don't know how to remove or hide that title bar. I found some solution but they didn't work such as window.setWindowFlags(Qt::Window | Qt::FramelessWindowHint);

The screen like as below:
13175

d_stranz
2nd July 2019, 05:11
The title bar is probably -not- the title bar of the QWidget that is inside the QTabWidget. Instead it is the title bar that your window system (Windows, X, MacOS) puts on top-level windows. If your tab widget is the top-level widget for your app, and you do not want it to have a title bar, then you will want to set the FramelessWindowHint window flag. Be warned though - without a frame, you will probably not be able to move the window around the desktop using the mouse, nor will you be able to maximize, minimize, or close the window with the mouse.

duongtan_pfiev
8th July 2019, 13:41
I am sure that title bar is Qwidget title bar inside QTabWidget because when I minimize that Qwidget, it disappear.
I tried many way to remove it but impossible
This is my Layout, could you help me to remove it?

d_stranz
8th July 2019, 15:40
According to your UI file, you have commented out the code that sets the "centralWidget" and have replaced it with a QTabWidget that is simply a child of the QMainWindow and not the centralWidget. You have also commented out the code for the menu bar and the status bar. Qt is therefore doing the best it can to create a UI on screen according to your broken specification.

Tab widgets are not top-level widgets and do not have title bars, but it is possible that Qt is thinking it is also taking the place of a top-level widget, so the operating system (not Qt) is putting a title bar on it. That is sort of implied because there does not seem to be a window title in it from what I can see in the screenshot. A MainWindow title bar would have the app name in it.

If you do not want the features of a QMainWindow in your app, then do not use it as the main top-level container widget. Use QDialog instead, and set the frameless hint. However, make sure you put your top-level tab widget into a layout for the QDialog (hbox or vbox, it doesn't matter since there is only one widget). If you do not use a layout, then the tab widget will not resize with the dialog.