PyQt5 QSpinBox – Setting caption to it
Last Updated :
17 May, 2020
In this article we will see how we can set caption to the spin box, caption is basically the heading of the spin box but it is not visible caption is for only back end purposes. Caption of spin box is similar to the caption of the main window.
In order to do so we use setWindowTitle
method.
Syntax : spin_box.setWindowTitle(caption)
Argument : It takes string as argument
Return : It returns None
Below is the implementation
from PyQt5.QtWidgets import *
from PyQt5 import QtCore, QtGui
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import sys
class Window(QMainWindow):
def __init__( self ):
super ().__init__()
self .setWindowTitle( "Python " )
self .setGeometry( 100 , 100 , 600 , 400 )
self .UiComponents()
self .show()
def UiComponents( self ):
self .spin = QSpinBox( self )
self .spin.setGeometry( 100 , 100 , 250 , 40 )
self .spin.setPrefix( "Prefix " )
self .spin.setSuffix( " Suffix" )
caption = "Spin Box 01"
self .spin.setWindowTitle(caption)
App = QApplication(sys.argv)
window = Window()
sys.exit(App. exec ())
|
Output :
Share your thoughts in the comments
Please Login to comment...