class InvokeEvent(QEvent): EVENT_TYPE = QEvent.Type(QEvent.registerEventType()) def __init__(self, fn, *args, **kwargs): QEvent.__init__(self, InvokeEvent.EVENT_TYPE) self.fn = fn self.args = args self.kwargs = kwargs
def closeEvent(self, event: QtCore.QEvent): if self._base_check_is_modified(): event.ignore() return self.unload_document() self.base_stop_threads = True for thread in self.base_threads: thread.join() super().closeEvent(event)
class TestEvent(QEvent): TestEventType = QEvent.Type(QEvent.registerEventType()) def __init__(self, rand=0): super(TestEvent, self).__init__(TestEvent.TestEventType) self._rand = rand def getRand(self): return self._rand
def testFlagAccess(self): #QEvent.Type flags usage event = QEvent(QEvent.Timer) self.assertEqual(event.type(), QEvent.Timer) event = QEvent(QEvent.Close) self.assertEqual(event.type(), QEvent.Close) event = QEvent(QEvent.IconTextChange) self.assertEqual(event.type(), QEvent.IconTextChange)
def on_actionCopyInspectorData_triggered(self): string = 'Node inspector data\n-------------------' # raise() for qModelIndex in self.ui.nodeInspector.selectedIndexes(): string += '\n' + qModelIndex.internalPointer().toString(' ') clipboard = app.clipboard() clipboard.setText(string) event = QEvent(QEvent.Clipboard) app.sendEvent(clipboard, event)
from PySide.QtCore import QEvent, Qt import PySide import unittest TEST_EVENT_TYPE = QEvent.Type(QEvent.registerEventType()) class TestEvent(QEvent): TestEventType = QEvent.Type(QEvent.registerEventType()) def __init__(self, rand=0): super(TestEvent, self).__init__(TestEvent.TestEventType) self._rand = rand def getRand(self): return self._rand class TestEnums(unittest.TestCase): def testUserTypesValues(self): self.assert_( QEvent.User <= int(TestEvent.TestEventType) <= QEvent.MaxUser) self.assert_(QEvent.User <= int(TEST_EVENT_TYPE) <= QEvent.MaxUser) def testUserTypesRepr(self): self.assertEqual(eval(repr(TestEvent.TestEventType)), TestEvent.TestEventType) self.assertEqual(eval(repr(TEST_EVENT_TYPE)), TEST_EVENT_TYPE)
def __init__(self, i): print("TYPE:", type(QEvent.User)) super(MyEvent, self).__init__(QEvent.Type(QEvent.User + 100)) self.i = i
from PySide.QtCore import QEvent, Qt import PySide import unittest TEST_EVENT_TYPE = QEvent.Type(QEvent.registerEventType()) class TestEvent(QEvent): TestEventType = QEvent.Type(QEvent.registerEventType()) def __init__(self, rand=0): super(TestEvent, self).__init__(TestEvent.TestEventType) self._rand = rand def getRand(self): return self._rand class TestEnums(unittest.TestCase): def testUserTypesValues(self): self.assert_(QEvent.User <= int(TestEvent.TestEventType) <= QEvent.MaxUser) self.assert_(QEvent.User <= int(TEST_EVENT_TYPE) <= QEvent.MaxUser) def testUserTypesRepr(self): self.assertEqual(eval(repr(TestEvent.TestEventType)), TestEvent.TestEventType) self.assertEqual(eval(repr(TEST_EVENT_TYPE)), TEST_EVENT_TYPE) if __name__ == '__main__': unittest.main()
def __init__(self): QEvent.__init__(self, QEvent.Type(999))
def __init__(self, fn, *args, **kwargs): QEvent.__init__(self, InvokeEvent.EVENT_TYPE) self.fn = fn self.args = args self.kwargs = kwargs