| 18 | class WindowSlave(QWidget): |
| 19 | |
| 20 | def __init__(self, *args, **kwargs): |
| 21 | super(WindowSlave, self).__init__(*args, **kwargs) |
| 22 | self.setupUi() |
| 23 | # 加入Master节点 |
| 24 | node = QRemoteObjectNode(parent=self) |
| 25 | node.connectToNode(QUrl('local:WindowMaster')) |
| 26 | # 获取WindowMaster对象 |
| 27 | self.windowMaster = node.acquireDynamic('WindowMaster') |
| 28 | # 初始化成功后才能去绑定信号等 |
| 29 | self.windowMaster.initialized.connect(self.onInitialized) |
| 30 | # 状态改变 https://doc.qt.io/qt-5/qremoteobjectreplica.html#State-enum |
| 31 | self.windowMaster.stateChanged.connect(self.onStateChanged) |
| 32 | |
| 33 | def setupUi(self): |
| 34 | self.setWindowTitle('WindowSlave') |