When we design the GUI (Graphical User Interface) application using PyQt5, there exist the window. A window is a (usually) rectangular portion of the display on a computer monitor that presents its contents (e.g., the contents of a directory, a text file or an image) seemingly independently of the rest of the screen. Windows are one of the elements that comprise a graphical user interface (GUI).
In a window we can see there exist a title bar which comprises the icon and title on the left size and on the right side there exist control button.

In this article we will see how we can hide title bar. In order to do so we will use setWindowFlag()
method and pass which belongs to the QWidget class
.
Syntax : setWindowFlag(Qt.FramelessWindowHint)
Argument : It takes Window type as argument.
Action performed : It removes the title bar.
Code :
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import Qt
import sys
class Window(QMainWindow):
def __init__( self ):
super ().__init__()
self .setWindowFlag(Qt.FramelessWindowHint)
self .setWindowTitle( "no title" )
self .setGeometry( 100 , 100 , 400 , 300 )
self .label_1 = QLabel( 'no title bar' , self )
self .label_1.move( 100 , 100 )
self .label_1.setStyleSheet("background - color: lightgreen;
border: 3px solid green")
self .show()
App = QApplication(sys.argv)
window = Window()
sys.exit(App. exec ())
|
Output :
