Copy # -*- coding: UTF-8 -*-
import sys
from PyQt5 . QtWidgets import *
from PyQt5 import QtGui
from PyQt5 . QtCore import Qt
class App ( QCheckBox ) :
def __init__ ( self ):
super (App, self). __init__ ()
self . setWindowTitle ( 'Window!!!' )
self . resize ( 600 , 600 )
self . setStyleSheet ( 'color:red;font-size:45px;' )
self . setText ( '확인' )
if __name__ == '__main__' :
app = QApplication (sys.argv)
window = App ()
window . show ()
sys . exit (app. exec_ ())
Copy # -*- coding: UTF-8 -*-
import sys
from PyQt5 . QtWidgets import *
from PyQt5 import QtGui
from PyQt5 . QtCore import Qt
class App ( QCheckBox ) :
def __init__ ( self ):
super (App, self). __init__ ()
self . setWindowTitle ( 'Window!!!' )
self . resize ( 600 , 600 )
self . setStyleSheet ( 'color:red;font-size:45px;' )
self . setText ( '확인' )
self . stateChanged . connect (self.changeCheckState)
def changeCheckState ( self , state ):
if state == Qt . Checked :
self . setText ( "Checked!!" )
else :
self . setText ( "Unchecked!!" )
if __name__ == '__main__' :
app = QApplication (sys.argv)
window = App ()
window . show ()
sys . exit (app. exec_ ())
13 stateChanged(상태가 변경되면) .connect(어떤일을 수행하겠다)
14 13번 라인의 connect에 의해 연결고리가 맺어지면 changeCheckState 함수가 호출될 때 state 값이 넘어 옵니다.
이때 넘어오는 값이 Qt.Checked 값과 같은지 비교를 합니다.