user3471696
user3471696

Reputation: 13

PyQt signal between modules

I can not understand one's probably a very simple thing. How from one module (Main.py) make changes (call functions ) in other module (module2.py), which is connected as QDockWidget to MainWindow, and see these changes immediately?

Upvotes: 0

Views: 1238

Answers (1)

justengel
justengel

Reputation: 6320

You have to declare a signal in the class then connect the signal to a function.

class MyClass(QtCore.QObject): # Could be QWidget must be inherited from QObject
    mysignal = QtCore.pyqtSignal(int, int, int, int) # types to pass values to the method call
    ...


myclass = MyClass()
other = QtGui.QMainWindow()

myclass.mysignal.connect(other.setGeometry)
myclass.mysignal.emit(0, 0, 1, 1)

http://pyqt.sourceforge.net/Docs/PyQt4/new_style_signals_slots.html

Upvotes: 3

Related Questions