(self, *args, **kwargs)
| 22 | class Window(QWidget): |
| 23 | |
| 24 | def __init__(self, *args, **kwargs): |
| 25 | super(Window, self).__init__(*args, **kwargs) |
| 26 | self.m_obj = WebChannelObject(self) |
| 27 | # 注册该窗口,可以访问该窗口的属性,槽函数,信号 |
| 28 | # https://doc.qt.io/qt-5/qwidget.html#properties |
| 29 | # https://doc.qt.io/qt-5/qwidget.html#signals |
| 30 | # https://doc.qt.io/qt-5/qwidget.html#public-slots |
| 31 | self.m_obj.registerObject('qtwindow', self) |
| 32 | self.m_obj.start() |
| 33 | |
| 34 | layout = QVBoxLayout(self) |
| 35 | self.editTitle = QLineEdit(self, placeholderText='输入标题') |
| 36 | layout.addWidget(self.editTitle) |
| 37 | layout.addWidget(QPushButton('修改标题', self, clicked=self.onChangeTitle)) |
| 38 | |
| 39 | QDesktopServices.openUrl( |
| 40 | QUrl.fromLocalFile( |
| 41 | os.path.join(os.path.dirname(sys.argv[0] or __file__), |
| 42 | 'Data/CallEachWithJs.html'))) |
| 43 | |
| 44 | def onChangeTitle(self): |
| 45 | self.setWindowTitle(self.editTitle.text()) |
nothing calls this directly
no test coverage detected