Pyqt 학습 노트

1370 단어 PyQt5 학습
PyQt에서,class는 모두 QObject에서 파생된 것이기 때문에,QWidget 대상은parent가 있을 수 있습니다.이런 parent-child 관계는 주로 두 가지 측면에 사용된다.
parent가 없는 QWidget 클래스는 최상층 창 (대개 Main Window) 으로 여겨집니다. Main Window의 일부 조작으로 생성된 새로운 창 대상이기 때문에,parent는Main Window를 가리켜야 합니다.parent-child 관계의 존재로 인해,child 창은 메인 창이 회수될 때도 회수될 수 있습니다.parent는 구조 함수의 마지막 매개 변수로 전송되지만, 일반적인 경우parent 대상을 지정할 필요가 없습니다.부국 관리자를 호출할 때 부국 관리자가 이런parent-child 관계를 자동으로 처리하기 때문이다.그러나 일부 특수한 경우, 우리가 지정한parent-child 관계를 표시해야 합니다.만약 생성된 하위 클래스가 QWidget 대상이 아니지만 QObject 대상을 계승하여 dock widgets의 QWidget 대상으로 사용된다면.
 
대상 간에 의존과 라이프 사이클이 생기면서 IOC 용기를 GUI 프로그래밍에 활용하는 것은 자연스러운 일이라는 것을 알 수 있다. 
# -*- coding: utf-8 -*- 

'''
    【 】
	PyQT5 
  
  
'''

import sys
from PyQt5.QtWidgets import QMainWindow , QApplication
from PyQt5.QtGui import QIcon 

class MainWidget(QMainWindow):				// QMainWindow
	def __init__(self,parent=None):
		super(MainWidget,self).__init__(parent)			// : MainWidget , __init__()
        #  
		self.setWindowTitle("QMainWindow  ")         
		self.resize(400, 200) 
		self.status = self.statusBar()						// 
		self.status.showMessage(" ",5000)		// ( , ( ))


if __name__ == "__main__": 
	app = QApplication(sys.argv)
	app.setWindowIcon(QIcon("./images/cartoon1.ico"))
	main = MainWidget()
	main.show()
	sys.exit(app.exec_())

좋은 웹페이지 즐겨찾기