pyside6 에서 QUiLoader 로 ui 불러와서 사용할 때 이벤트 동작 안될 때

728x90
from PySide6.QtUiTools import QUiLoader


class Dialog(Dialog):
	def __init__(self):
        super(Dialog, self).__init__()
        loader = QUiLoader()
        ui = loader.load('ui/dialog.ui') # 로더로 ui 를 불러온다.
        ui.installEventFilter(self) # 이벤트 필터를 self 를 사용하여 해당 클래스에 있는 이벤트 필터로 재정의
   
    def eventFilter(self, o, e):
        if e.type() == QEvent.Type.MouseButtonPress: # 해당이벤트에 대해 동작
            print("click")
            return True
        return False    # 다른 이벤트의 대해서 false 로 리턴
반응형