Set title of window in PyQt5 – setWindowTitle
PyQt5 is a comprehensive set of Python bindings for Qt v5. It is implemented as more than 35 extension modules and enables Python to be used as an alternative application development language to C++ on all supported platforms including iOS and Android.
In this article, we will see how to set title of the window in PyQt5. In order to do so setWindowTitle() method is used, this method belongs to the QWidget class.
Syntax : self.setWindowTitle(title)
Argument : It takes title i.e string as argument.
Below is the Python implementation –
Python3
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import sys
class Window(QMainWindow):
def __init__( self ):
super ().__init__()
title = "Title of window"
self .setWindowTitle(title)
self .setGeometry( 0 , 0 , 500 , 300 )
self .show()
App = QApplication(sys.argv)
window = Window()
sys.exit(App. exec ())
|
Output :
Last Updated :
24 Nov, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...