初始化以下变量并在QStatusBar中添加,每两个QLabel以QFrame竖线分割QLabel *m_testStateKeyLabel = nullptr; QLabel *m_testStateValueLabel = nullptr; QLabel *m_testOverTimeKeyLabel = nullptr; QLabel *m_testOverTimeValueLabel = nullptr; QLabel *m_flowOverTimeKeyLabel = nullptr; QLabel *m_flowOverTimeValueLabel = nullptr; QLabel *m_signalCharacteristicsValueLabel = nullptr; QLabel *m_deviationValueLabel = nullptr; QLabel *m_coolantKeyLabel = nullptr; QLabel *m_coolantValueLabel = nullptr;
时间: 2024-02-03 18:12:57 浏览: 73
以下是初始化变量并添加到QStatusBar的代码示例:
```cpp
// 初始化变量
m_testStateKeyLabel = new QLabel(tr("Test State: "));
m_testStateValueLabel = new QLabel(tr("Idle"));
m_testOverTimeKeyLabel = new QLabel(tr("Test Over Time: "));
m_testOverTimeValueLabel = new QLabel(tr("--:--:--"));
m_flowOverTimeKeyLabel = new QLabel(tr("Flow Over Time: "));
m_flowOverTimeValueLabel = new QLabel(tr("--:--:--"));
m_signalCharacteristicsValueLabel = new QLabel(tr("Signal Characteristics: "));
m_deviationValueLabel = new QLabel(tr("Deviation: "));
m_coolantKeyLabel = new QLabel(tr("Coolant: "));
m_coolantValueLabel = new QLabel(tr("None"));
// 添加到QStatusBar
QFrame* separatorLine = new QFrame();
separatorLine->setFrameShape(QFrame::VLine);
statusBar()->addWidget(m_testStateKeyLabel);
statusBar()->addWidget(m_testStateValueLabel);
statusBar()->addWidget(separatorLine);
statusBar()->addWidget(m_testOverTimeKeyLabel);
statusBar()->addWidget(m_testOverTimeValueLabel);
statusBar()->addWidget(separatorLine);
statusBar()->addWidget(m_flowOverTimeKeyLabel);
statusBar()->addWidget(m_flowOverTimeValueLabel);
statusBar()->addWidget(separatorLine);
statusBar()->addWidget(m_signalCharacteristicsValueLabel);
statusBar()->addWidget(m_deviationValueLabel);
statusBar()->addWidget(separatorLine);
statusBar()->addWidget(m_coolantKeyLabel);
statusBar()->addWidget(m_coolantValueLabel);
```
这样就可以在QStatusBar中添加每两个QLabel以QFrame竖线分割的效果。
阅读全文