Reputation: 175
can i connect two objects that are in different classes ?
lets say i want button1's clicked() signal to clear line2
class A(QGroupBox):
def __init__(self, parent=None):
super(A, self).__init__(parent)
self.button1= QPushButton('bt1')
self.button1.show()
class B(QGroupBox):
def __init__(self, parent=None):
super(B, self).__init__(parent)
self.line2 = QLineEdit()
self.line2.show()
ob1 = A()
ob2 = B()
Upvotes: 2
Views: 2841
Reputation: 273416
Yes, create a method in object B that's tied to a signal in object A. Note how connect
is called (this is just an example):
self.connect(self.okButton, QtCore.SIGNAL("clicked()"),
self, QtCore.SLOT("accept()"))
The third argument is the object with the slot, and the fourth the slot name. The sending and receiving objects can definitely be different.
Upvotes: 3