PyQt5 QSpinBox – Setting object name
Last Updated :
10 May, 2020
In this article we will see how we can set the object name of the spin box, object name is basically name given to the object of spin box, when we find the object in the PyQt5 application with the help of object name with the help of findChild
method.
In order to do this we will use setObjectName
method..
Syntax : spin_box.setObjectName(name)
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 , 150 , 40 )
self .spin.setSuffix( " Spin Box" )
name = "Geeky"
self .spin.setObjectName(name)
App = QApplication(sys.argv)
window = Window()
sys.exit(App. exec ())
|
Output :
Share your thoughts in the comments
Please Login to comment...