45 lines
1.5 KiB
Markdown
45 lines
1.5 KiB
Markdown
|
|
# 实施方案 - 同步数值数据左对齐
|
|||
|
|
|
|||
|
|
## 背景
|
|||
|
|
用户要求同步过来的数值数据需要左对齐。目前的 UI 界面中,数值数据(如化学元素含量、批次信息等)在某些地方可能是居中对齐的。
|
|||
|
|
|
|||
|
|
## 方案步骤
|
|||
|
|
|
|||
|
|
### 1. 修改 `ui/incoming_inspection_page.py`
|
|||
|
|
- 修改 `create_input` 方法,为生成的 `QLineEdit` 设置 `Qt.AlignLeft | Qt.AlignVCenter`。
|
|||
|
|
- 修改 `update_ui_with_data` 中的样式设置(如果有影响)。
|
|||
|
|
|
|||
|
|
### 2. 修改 `ui/manual_inspection_page.py`
|
|||
|
|
- 同样修改 `create_input` 方法,设置左对齐。
|
|||
|
|
|
|||
|
|
### 3. 修改 `ui/inspection_card.py`
|
|||
|
|
- 调整 `add_cell` 方法。目前的 `add_cell` 统一设置了 `Qt.AlignCenter`。
|
|||
|
|
- 需要区分标头(Header)和内容(Value)。标头可以保持居中,但内容(Value)应设置为左对齐。
|
|||
|
|
|
|||
|
|
## 修改细节
|
|||
|
|
|
|||
|
|
### Incoming/Manual Inspection Page
|
|||
|
|
```python
|
|||
|
|
def create_input(self, key):
|
|||
|
|
inp = QLineEdit()
|
|||
|
|
inp.setAlignment(Qt.AlignLeft | Qt.AlignVCenter) # 显式设置左对齐
|
|||
|
|
...
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### Inspection Card
|
|||
|
|
```python
|
|||
|
|
def add_cell(text, row, col, row_span=1, col_span=1, is_header=False):
|
|||
|
|
lbl = QLabel(text)
|
|||
|
|
if is_header:
|
|||
|
|
lbl.setAlignment(Qt.AlignCenter) # 标头居中
|
|||
|
|
else:
|
|||
|
|
lbl.setAlignment(Qt.AlignLeft | Qt.AlignVCenter) # 数值左对齐
|
|||
|
|
...
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 验证计划
|
|||
|
|
- 启动应用程序。
|
|||
|
|
- 进入“入检”和“手检”界面。
|
|||
|
|
- 执行同步操作,观察元素数值是否左对齐。
|
|||
|
|
- 观察主页面的卡片数据是否左对齐。
|