修改为使用QLinedit输入型号,偏基础移量测试

This commit is contained in:
2024-09-09 03:09:27 +08:00
parent 2ce0d7b876
commit 431823dd72
24 changed files with 145 additions and 25 deletions
@@ -29,13 +29,23 @@ public:
QVBoxLayout* layout = new QVBoxLayout(this);
fancyButtonText* switchBtn = new fancyButtonText(100, 60, "修改", "修改当前机型");
QLabel* armHeartBeatSign = new QLabel();
//料号条码输入
QLineEdit* partNumberIntputLine = new QLineEdit();
//运行按钮
fancyButtonText* startBtn;
//SN条码输入
QLineEdit* snIntputLine = new QLineEdit();
//料号显示
QComboBox* productSelect = new QComboBox(this);
QComboBox* productSelect = new QComboBox(this);
QLabel* currentProduct = new QLabel(this);
//料号类型
QComboBox* productNameTypeSwitch = new QComboBox(this);
void clear()
{
partNumberIntputLine->clear();
snIntputLine->clear();
}
switchProductWidget()
{
currentProductIndexPtr = &_core._appConfig._switchProductWidgetDataPtr.currentProductIndex;
@@ -68,19 +78,28 @@ public:
layout->addLayout(switchLayout);
}
snIntputLine->setFixedHeight(50);
snIntputLine->setFont(font);
QHBoxLayout* hBtnLayout2 = new QHBoxLayout();
partNumberIntputLine->setFixedHeight(50);
partNumberIntputLine->setFont(font);
partNumberIntputLine->setPlaceholderText("料号条码输入");
hBtnLayout2->addWidget(partNumberIntputLine);
QHBoxLayout* hBtnLayout = new QHBoxLayout();
startBtn = new fancyButtonText(80, -1, "运行", "运行检测程序");
snIntputLine->setFixedHeight(50);
snIntputLine->setFont(font);
snIntputLine->setPlaceholderText("SN条码输入");
hBtnLayout->addWidget(snIntputLine);
hBtnLayout->addWidget(startBtn);
layout->addLayout(hBtnLayout2);
layout->addLayout(hBtnLayout);
productSelectFresh(0);
connect(startBtn, &QPushButton::clicked, this, [=]()
{
emit startArmProgramSignal(productSelect->currentIndex(), snIntputLine->text());
emit startArmProgramSignal(indexFromPartNumber, snIntputLine->text());
std::cout << "按下按钮" << std::endl;
});
connect(switchBtn, &QPushButton::clicked, this, &switchProductWidget::startSwitch);
@@ -93,6 +112,14 @@ public:
{
productSelectFresh(productNameTypeSwitch->currentIndex());
});
connect(partNumberIntputLine, &QLineEdit::textChanged, this, [=]()
{
partNumberIntputLineSlot(partNumberIntputLine->text().toStdString());
});
currentProduct->setText("请输入料号");
productSelect->hide();
switchBtn->hide();
startBtn->setDisabled(true);
}
void productSelectFresh(int index)
{
@@ -138,7 +165,7 @@ public slots:
if (status == true)
{
startBtn->toDefault();
if(disableTextChange == false)
if (disableTextChange == false)
startBtn->setText("运行");
snIntputLine->setDisabled(false);
std::cout << "按下软件运行" << std::endl;
@@ -156,8 +183,27 @@ signals:
void startArmProgramSignal(int,QString);
void switchProductSignal(int);
private:
int indexFromPartNumber = -1;
int siwtchBtnState = 0;
private slots:
void partNumberIntputLineSlot(std::string partNumber)
{
auto it = _core._appConfig.partNumberWithIndex.find(partNumber);
if(it != _core._appConfig.partNumberWithIndex.end())
{
int index = _core._appConfig.partNumberWithIndex.find(partNumber)->second;
currentProduct->setText(QString::fromStdString(_core._appConfig.productDatas[index].name));
*currentProductIndexPtr = index;
startBtn->setEnabled(true);
indexFromPartNumber = index;
snIntputLine->setFocus();
}
else
{
currentProduct->setText("未找到对应料号!");
startBtn->setDisabled(true);
}
}
void startSwitch()
{
if(siwtchBtnState == 0)