当前位置: 首页>>代码示例>>Python>>正文


Python QObject.connect方法代码示例

本文整理汇总了Python中PySide2.QtCore.QObject.connect方法的典型用法代码示例。如果您正苦于以下问题:Python QObject.connect方法的具体用法?Python QObject.connect怎么用?Python QObject.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PySide2.QtCore.QObject的用法示例。


在下文中一共展示了QObject.connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: from PySide2.QtCore import QObject [as 别名]
# 或者: from PySide2.QtCore.QObject import connect [as 别名]
 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
开发者ID:BadSingleton,项目名称:pyside2,代码行数:9,代码来源:webview_test.py

示例2: testSimplePythonSignalNoArgs

# 需要导入模块: from PySide2.QtCore import QObject [as 别名]
# 或者: from PySide2.QtCore.QObject import connect [as 别名]
 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)
开发者ID:BadSingleton,项目名称:pyside2,代码行数:9,代码来源:lambda_test.py

示例3: testIt

# 需要导入模块: from PySide2.QtCore import QObject [as 别名]
# 或者: from PySide2.QtCore.QObject import connect [as 别名]
 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)
开发者ID:BadSingleton,项目名称:pyside2,代码行数:9,代码来源:signal_emission_test.py

示例4: testButtonClick

# 需要导入模块: from PySide2.QtCore import QObject [as 别名]
# 或者: from PySide2.QtCore.QObject import connect [as 别名]
 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)
开发者ID:BadSingleton,项目名称:pyside2,代码行数:9,代码来源:signal_emission_gui_test.py

示例5: testButtonClicked

# 需要导入模块: from PySide2.QtCore import QObject [as 别名]
# 或者: from PySide2.QtCore.QObject import connect [as 别名]
 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)
开发者ID:BadSingleton,项目名称:pyside2,代码行数:9,代码来源:signal_emission_gui_test.py

示例6: run

# 需要导入模块: from PySide2.QtCore import QObject [as 别名]
# 或者: from PySide2.QtCore.QObject import connect [as 别名]
    def run(self):
        global thread_run
        thread_run = True
        QObject.connect(self.source, SIGNAL('source()'), self.target.myslot)

        while not self.target.called:
            pass
开发者ID:BadSingleton,项目名称:pyside2,代码行数:9,代码来源:qthread_signal_test.py

示例7: testValueChanged

# 需要导入模块: from PySide2.QtCore import QObject [as 别名]
# 或者: from PySide2.QtCore.QObject import connect [as 别名]
        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)
开发者ID:linzhun,项目名称:pyside2,代码行数:9,代码来源:pysignal_test.py

示例8: testQThreadReceiversExtern

# 需要导入模块: from PySide2.QtCore import QObject [as 别名]
# 或者: from PySide2.QtCore.QObject import connect [as 别名]
    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)
开发者ID:BadSingleton,项目名称:pyside2,代码行数:9,代码来源:qobject_protected_methods_test.py

示例9: testMetaData

# 需要导入模块: from PySide2.QtCore import QObject [as 别名]
# 或者: from PySide2.QtCore.QObject import connect [as 别名]
 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_()
开发者ID:BadSingleton,项目名称:pyside2,代码行数:9,代码来源:webframe_test.py

示例10: testQObjectReceiversExtern

# 需要导入模块: from PySide2.QtCore import QObject [as 别名]
# 或者: from PySide2.QtCore.QObject import connect [as 别名]
    def testQObjectReceiversExtern(self):
        #QObject.receivers() - Protected method external access

        obj = Dummy()
        self.assertEqual(obj.receivers(SIGNAL("destroyed()")), 0)

        QObject.connect(obj, SIGNAL("destroyed()"), self.cb)
        self.assertEqual(obj.receivers(SIGNAL("destroyed()")), 1)
开发者ID:BadSingleton,项目名称:pyside2,代码行数:10,代码来源:qobject_protected_methods_test.py

示例11: testSimplePythonSignal

# 需要导入模块: from PySide2.QtCore import QObject [as 别名]
# 或者: from PySide2.QtCore.QObject import connect [as 别名]
 def testSimplePythonSignal(self):
     #Connecting a lambda to a simple python signal witharguments
     obj = Dummy()
     arg = 42
     QObject.connect(obj, SIGNAL('foo(int)'),
                     lambda x: setattr(obj, 'arg', 42))
     obj.emit(SIGNAL('foo(int)'), arg)
     self.assertEqual(obj.arg, arg)
开发者ID:BadSingleton,项目名称:pyside2,代码行数:10,代码来源:lambda_test.py

示例12: testDefaultArgs

# 需要导入模块: from PySide2.QtCore import QObject [as 别名]
# 或者: from PySide2.QtCore.QObject import connect [as 别名]
    def testDefaultArgs(self):
        #QUdpSocket.readDatagram pythonic return
        # @bug 124
        QObject.connect(self.server, SIGNAL('readyRead()'), self.callback)
        self.sendPackage()
        self.app.exec_()

        self.assert_(self.called)
开发者ID:BadSingleton,项目名称:pyside2,代码行数:10,代码来源:udpsocket_test.py

示例13: testThread

# 需要导入模块: from PySide2.QtCore import QObject [as 别名]
# 或者: from PySide2.QtCore.QObject import connect [as 别名]
    def testThread(self):
        t = MyThread()
        QObject.connect(t, SIGNAL("test(const QString&)"), self._callback);
        t.start()

        self.app.exec_()
        t.wait()
        self.assert_(self.__called__);
开发者ID:BadSingleton,项目名称:pyside2,代码行数:10,代码来源:thread_signals_test.py

示例14: testNoArgs

# 需要导入模块: from PySide2.QtCore import QObject [as 别名]
# 或者: from PySide2.QtCore.QObject import connect [as 别名]
    def testNoArgs(self):
        """Short circuit signal without arguments"""
        obj1 = Dummy()

        QObject.connect(obj1, SIGNAL('foo'), self.callback)
        self.args = tuple()
        obj1.emit(SIGNAL('foo'), *self.args)

        self.assert_(self.called)
开发者ID:BadSingleton,项目名称:pyside2,代码行数:11,代码来源:short_circuit_test.py

示例15: testWithArgs

# 需要导入模块: from PySide2.QtCore import QObject [as 别名]
# 或者: from PySide2.QtCore.QObject import connect [as 别名]
    def testWithArgs(self):
        """Python signal and slots with integer arguments"""
        obj1 = Dummy()

        QObject.connect(obj1, SIGNAL("foo(int)"), self.callback)
        self.args = (42,)
        obj1.emit(SIGNAL("foo(int)"), *self.args)

        self.assert_(self.called)
开发者ID:linzhun,项目名称:pyside2,代码行数:11,代码来源:pysignal_test.py


注:本文中的PySide2.QtCore.QObject.connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。