#include "showxiangdanlabelform.h" #include "ui_showxiangdanlabelform.h" #include "QDebug" ShowXiangDanLabelForm::ShowXiangDanLabelForm(QWidget *parent) : QWidget(parent), ui(new Ui::ShowXiangDanLabelForm) { ui->setupUi(this); ui->ModelList->setRowCount(1); ui->ModelList->setItem(0,0,new QTableWidgetItem("test")); ui->showWidget->setAutoFillBackground(true); addComboBox(); controlHide(); } ShowXiangDanLabelForm::~ShowXiangDanLabelForm() { delete ui; } void ShowXiangDanLabelForm::on_backButton_clicked() { emit back(); } void ShowXiangDanLabelForm::on_ModelList_cellClicked(int row, int column) { if(ui->addNewModel->text() == "保存模板"){ if(row!=ui->ModelList->rowCount()-1){ QMessageBox::information(this,tr("警告"),tr("请先保存当前新建模板")); return; } } if(row == 0){ QImage image; image.load(":/images/moren.bmp"); QPalette palette; _boxPrinter.reset(new BoxTemlateOne()); palette.setBrush(ui->showWidget->backgroundRole(), QBrush(image.scaled(// 缩放背景图. ui->showWidget->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation))); ui->showWidget->setPalette(palette); } } void ShowXiangDanLabelForm::on_addNewModel_clicked() { if(ui->addNewModel->text() == "新建模板"){ // qDebug()<ModelList->rowCount(); ui->ModelList->setRowCount(ui->ModelList->rowCount()+1); ui->ModelList->setItem(ui->ModelList->rowCount()-1,0,new QTableWidgetItem("请输入名称")); controlShow(); QPalette palette; _boxPrinter.reset(new BoxTemlateOne()); palette.setBrush(ui->showWidget->backgroundRole(), QBrush(_boxPrinter->BoxModel().scaled(// 缩放背景图. ui->showWidget->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation))); ui->showWidget->setPalette(palette); ui->addNewModel->setText("保存模板"); }else if(ui->addNewModel->text() == "保存模板"){ if(ui->ModelList->item(ui->ModelList->rowCount(),0)->text()=="请输入名称"){ QMessageBox::information(this,tr("提示"),tr("请输入名称")); return; } QMessageBox::information(this,tr("提示"),tr("保存成功")); ui->addNewModel->setText("新建模板"); } } void ShowXiangDanLabelForm::on_upModel_clicked() { controlShow(); } void ShowXiangDanLabelForm::controlHide() { ui->text1->hide();//第一行从上而下 ui->text2->hide(); ui->text3->hide(); ui->text4->hide(); ui->text5->hide(); ui->text1_2->hide();//第二行从上而下 ui->text2_2->hide(); ui->text3_2->hide(); ui->text4_2->hide(); ui->text5_2->hide(); ui->data1->hide(); ui->data2->hide(); ui->data3->hide(); ui->data4->hide(); ui->data5->hide(); ui->data1_2->hide(); ui->data2_2->hide(); ui->data3_2->hide(); ui->data4_2->hide(); ui->data5_2->hide(); } void ShowXiangDanLabelForm::controlShow() { ui->text1->show();//第一行从上而下 ui->text2->show(); ui->text3->show(); ui->text4->show(); ui->text5->show(); ui->text1_2->show();//第二行从上而下 ui->text2_2->show(); ui->text3_2->show(); ui->text4_2->show(); ui->text5_2->show(); ui->data1->show(); ui->data2->show(); ui->data3->show(); ui->data4->show(); ui->data5->show(); ui->data1_2->show(); ui->data2_2->show(); ui->data3_2->show(); ui->data4_2->show(); ui->data5_2->show(); } void ShowXiangDanLabelForm::addComboBox() { QList text; text.append("品名"); text.append("批号"); text.append("规格"); text.append("等级"); text.append("箱号"); text.append("毛重"); text.append("净重"); text.append("筒数"); text.append("捻向"); text.append("纸管颜色"); QList data; data.append("product_type_code"); data.append("batch_no"); data.append("specs"); data.append("level"); data.append("case_number"); data.append("gross_weight"); data.append("net_weight"); data.append("tube_number"); data.append("twist_type"); data.append("bucket_color"); for(int i = 0;idata1->addItem(text.at(i),data.at(i)); } for(int i = 0;idata2->addItem(text.at(i),data.at(i)); } for(int i = 0;idata3->addItem(text.at(i),data.at(i)); } for(int i = 0;idata4->addItem(text.at(i),data.at(i)); } for(int i = 0;idata5->addItem(text.at(i),data.at(i)); } for(int i = 0;idata1_2->addItem(text.at(i),data.at(i)); } for(int i = 0;idata2_2->addItem(text.at(i),data.at(i)); } for(int i = 0;idata3_2->addItem(text.at(i),data.at(i)); } for(int i = 0;idata4_2->addItem(text.at(i),data.at(i)); } for(int i = 0;idata5_2->addItem(text.at(i),data.at(i)); } }