def event(self, event: Qt.QEvent) -> bool: if event.type() in (Qt.QEvent.Polish, Qt.QEvent.ApplicationPaletteChange): self.setPalette(self.main.palette()) self.update() return True return super().event(event)
def notify(self, obj: Qt.QObject, event: Qt.QEvent) -> bool: import sys isex = False try: self.enter_count += 1 ret, time = cast( Tuple[bool, float], measure_exec_time_ms(Qt.QApplication.notify, True, False)(self, obj, event)) if (type(event).__name__ == 'QEvent' and event.type() in qevent_info): event_name = qevent_info[event.type()][0] else: event_name = type(event).__name__ try: obj_name = obj.objectName() except RuntimeError: obj_name = '' if obj_name == '': try: if (obj.parent() is not None and obj.parent().objectName() != ''): obj_name = '(parent) ' + obj.parent().objectName() except RuntimeError: pass recursive_indent = 2 * (self.enter_count - 1) print( f'{time:7.3f} ms, receiver: {type(obj).__name__:>25}, event: {event.type():3d} {" " * recursive_indent + event_name:<30}, name: {obj_name}' ) self.enter_count -= 1 return ret except Exception: # pylint: disable=broad-except isex = True logging.error('Application: unexpected error') print(*sys.exc_info()) return False finally: if isex: self.quit()
def eventFilter(self, obj: Qt.QObject, event: Qt.QEvent) -> bool: if (event.type() == Qt.QEvent.Show): logging.debug('--------------------------------') logging.debug(f'{obj.objectName()}') logging.debug('event: Show') logging.debug(f'spontaneous: {event.spontaneous()}') logging.debug('') self.print_toolbars_state() elif (event.type() == Qt.QEvent.Hide): logging.debug('--------------------------------') logging.debug(f'{obj.objectName()}') logging.debug('event: Hide') logging.debug(f'spontaneous: {event.spontaneous()}') logging.debug('') self.print_toolbars_state() # return Qt.QObject.eventFilter(object, event) return False
def event(self, event: Qt.QEvent) -> bool: if event.type() == Qt.QEvent.LayoutRequest: self.timeline.full_repaint() return super().event(event)
def changeEvent(self, event: QEvent): if event.type() == QEvent.WindowStateChange: # Если окно свернули if self.isMinimized(): # Прячем окно с панели задач QTimer.singleShot(0, self.hide)