60 lines
1.4 KiB
C++
60 lines
1.4 KiB
C++
#include <qwidget.h>
|
|
#include <qlabel.h>
|
|
#include <qcombobox.h>
|
|
#include <qlayout.h>
|
|
#include <qpushbutton.h>
|
|
class switchProductWidget : public QWidget
|
|
{
|
|
public:
|
|
int currentProductIndex = 0;
|
|
QHBoxLayout* layout = new QHBoxLayout(this);
|
|
fancyButtonText* switchBtn = new fancyButtonText(100, 60, "修改", "修改当前机型");
|
|
QComboBox* productSelect = new QComboBox(this);
|
|
QLabel* currentProduct = new QLabel(this);
|
|
switchProductWidget()
|
|
{
|
|
this->setLayout(layout);
|
|
|
|
productSelect->addItem("产品1");
|
|
productSelect->addItem("产品2");
|
|
|
|
layout->addWidget(productSelect);
|
|
productSelect->hide();
|
|
|
|
currentProduct->setText("产品1");
|
|
layout->addWidget(currentProduct);
|
|
layout->addWidget(switchBtn);
|
|
|
|
connect(switchBtn, &QPushButton::clicked, this, &switchProductWidget::startSwitch);
|
|
connect(productSelect, &QComboBox::currentTextChanged, this, &switchProductWidget::currentProductSwitch);
|
|
}
|
|
private:
|
|
int siwtchBtnState = 0;
|
|
private slots:
|
|
void startSwitch()
|
|
{
|
|
if(siwtchBtnState == 0)
|
|
{
|
|
currentProduct->hide();
|
|
productSelect->show();
|
|
switchBtn->setText("取消");
|
|
siwtchBtnState = 1;
|
|
return;
|
|
}
|
|
else if (siwtchBtnState == 1)
|
|
{
|
|
currentProduct->show();
|
|
productSelect->hide();
|
|
switchBtn->setText("修改");
|
|
siwtchBtnState = 0;
|
|
return;
|
|
}
|
|
|
|
}
|
|
void currentProductSwitch(QString input)
|
|
{
|
|
int index = productSelect->currentIndex();
|
|
}
|
|
};
|
|
|
|
#pragma once |