PyQt5 – nextCheckState() method for Check Box
Last Updated :
13 Jan, 2023
We can set the state of the check box using setChecked or for tristate check box we can set its states using setCheckState method. nextCheckState sets the next state of the check box i.e for default check box if initial check state is checked, it will set it to un-checked and vice versa. For tri-state check box if check state if un-checked it will set it to intermediate state and if initial state is intermediate, it will set it to checked and if it is checked it will set it to un-checked.
Syntax : checkbox.nextCheckState() Argument : It takes no argument. Action performed : It will change the state of check box according to the previous state.
Below is the implementation.
Python3
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 ):
checkbox = QCheckBox( 'Geek ?' , self )
checkbox.setGeometry( 200 , 150 , 100 , 40 )
checkbox.setTristate( True )
checkbox.nextCheckState()
App = QApplication(sys.argv)
window = Window()
sys.exit(App. exec ())
|
Output :
Share your thoughts in the comments
Please Login to comment...