本文整理汇总了Python中PySide2.QtCore.QObject类的典型用法代码示例。如果您正苦于以下问题:Python QObject类的具体用法?Python QObject怎么用?Python QObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testButtonClick
def testButtonClick(self):
"""Indirect qt signal emission using the QPushButton.click() method """
button = QPushButton('label')
QObject.connect(button, SIGNAL('clicked()'), self.cb)
self.args = tuple()
button.click()
self.assert_(self.called)
示例2: testIt
def testIt(self):
global called
called = False
o = QObject()
o.connect(o, SIGNAL("ASignal"), functools.partial(someSlot, "partial .."))
o.emit(SIGNAL("ASignal"))
self.assertTrue(called)
示例3: testMetaData
def testMetaData(self):
self.view = QWebView()
QObject.connect(self.view, SIGNAL('loadFinished(bool)'),
self.load_finished)
url = QUrl.fromLocalFile(adjust_filename('fox.html', __file__))
self.view.setUrl(url)
self.app.exec_()
示例4: __init__
def __init__(self, obj=None, event_type=None, *args):
#Creates a new filter object
QObject.__init__(self, *args)
self.obj = obj
self.event_type = event_type
self.events_handled = 0
self.events_bypassed = 0
示例5: timerEvent
def timerEvent(self, event):
QObject.timerEvent(self, event)
event.accept()
self.times_called += 1
if self.times_called == 5:
self.app.exit(0)
示例6: setUp
def setUp(self):
#Acquire resources
TimedQApplication.setUp(self, timeout=1000)
self.view = QWebView()
QObject.connect(self.view, SIGNAL('loadFinished(bool)'),
self.load_finished)
self.called = False
示例7: testQThreadReceiversExtern
def testQThreadReceiversExtern(self):
#QThread.receivers() - Inherited protected method
obj = QThread()
self.assertEqual(obj.receivers(SIGNAL('destroyed()')), 0)
QObject.connect(obj, SIGNAL("destroyed()"), self.cb)
self.assertEqual(obj.receivers(SIGNAL("destroyed()")), 1)
示例8: testButtonClicked
def testButtonClicked(self):
"""Connection of a python slot to QPushButton.clicked()"""
button = QPushButton('Mylabel')
QObject.connect(button, SIGNAL('clicked()'), self.cb)
self.args = tuple()
button.emit(SIGNAL('clicked(bool)'), False)
self.assert_(self.called)
示例9: testSimplePythonSignalNoArgs
def testSimplePythonSignalNoArgs(self):
#Connecting a lambda to a simple python signal without arguments
obj = Dummy()
QObject.connect(obj, SIGNAL('foo()'),
lambda: setattr(obj, 'called', True))
obj.emit(SIGNAL('foo()'))
self.assert_(obj.called)
示例10: testSimple
def testSimple(self):
#QObject.objectName(string)
name = 'object1'
obj = QObject()
obj.setObjectName(name)
self.assertEqual(name, obj.objectName())
示例11: testEmpty
def testEmpty(self):
#QObject.objectName('')
name = ''
obj = QObject()
obj.setObjectName(name)
self.assertEqual(name, obj.objectName())
示例12: testTrUtf8AsInstanceMethod
def testTrUtf8AsInstanceMethod(self):
#Test QObject.trUtf8 as instance
invar1 = 'test1'
outvar1 = QObject.trUtf8(self.obj, invar1)
invar2 = 'test2'
outvar2 = QObject.trUtf8(self.obj, invar2, 'test comment')
self.assertEqual((invar1, invar2), (outvar1, outvar2))
示例13: run
def run(self):
global thread_run
thread_run = True
QObject.connect(self.source, SIGNAL('source()'), self.target.myslot)
while not self.target.called:
pass
示例14: testValueChanged
def testValueChanged(self):
"""Emission of a python signal to QSpinBox setValue(int)"""
QObject.connect(self.obj, SIGNAL("dummy(int)"), self.spin, SLOT("setValue(int)"))
self.assertEqual(self.spin.value(), 0)
self.obj.emit(SIGNAL("dummy(int)"), 4)
self.assertEqual(self.spin.value(), 4)
示例15: testConnection
def testConnection(self):
o = TestObject(0)
c = QObject()
c.setObjectName("child")
self._child = None
o.childrenChanged.connect(self.childrenChanged)
o.addChild(c)
self.assertEquals(self._child.objectName(), "child")