(self, *args, **kwargs)
| 43 | |
| 44 | class TestWindow(QWidget): |
| 45 | def __init__(self, *args, **kwargs) -> None: |
| 46 | super().__init__(*args, **kwargs) |
| 47 | layout = QHBoxLayout(self) |
| 48 | self.treeView = QTreeView(self) |
| 49 | self.widgetEdit = QWidget(self) |
| 50 | layout.addWidget(self.treeView) |
| 51 | layout.addWidget(self.widgetEdit) |
| 52 | |
| 53 | layout = QFormLayout(self.widgetEdit) |
| 54 | layout.setFormAlignment(Qt.AlignLeft | Qt.AlignTop) |
| 55 | layout.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow) |
| 56 | self.editPath = QLineEdit(f"address{QJsonItem.Sep}city", self.widgetEdit) |
| 57 | self.editPath.setPlaceholderText( |
| 58 | f"请输入查询内容,支持路径查询,比如:aaa{QJsonItem.Sep}bbb{QJsonItem.Sep}ccc" |
| 59 | ) |
| 60 | layout.addRow("Path:", self.editPath) |
| 61 | self.editValue = QLineEdit("SiChuan", self.widgetEdit) |
| 62 | self.editValue.setPlaceholderText("请输入修改值,只支持路径匹配") |
| 63 | layout.addRow("Value:", self.editValue) |
| 64 | self.buttonQuery = QPushButton("查询", self.widgetEdit) |
| 65 | self.buttonModify = QPushButton("修改", self.widgetEdit) |
| 66 | self.buttonExport = QPushButton("获取Json", self.widgetEdit) |
| 67 | layout.addRow("", self.buttonQuery) |
| 68 | layout.addRow("", self.buttonModify) |
| 69 | layout.addRow("", self.buttonExport) |
| 70 | self.editText = QPlainTextEdit(self.widgetEdit) |
| 71 | self.editText.setReadOnly(True) |
| 72 | layout.addRow("", self.editText) |
| 73 | self.buttonQuery.clicked.connect(self.doQuery) |
| 74 | self.buttonModify.clicked.connect(self.doModify) |
| 75 | self.buttonExport.clicked.connect(self.doExport) |
| 76 | |
| 77 | self.model = QJsonModel(self) |
| 78 | self.model.itemChanged.connect(self.onItemChanged) |
| 79 | self.treeView.setModel(self.model) |
| 80 | |
| 81 | self.setupModel() |
| 82 | |
| 83 | def doQuery(self): |
| 84 | self.editText.clear() |
nothing calls this directly
no test coverage detected