#include "frmplot.h" #include "ui_frmplot.h" #include "quihelper.h" #include "frmplotpanel.h" frmPlot::frmPlot(QWidget *parent) : QWidget(parent), ui(new Ui::frmPlot) { ui->setupUi(this); this->initForm(); QTimer::singleShot(10, this, SLOT(initPanel())); } frmPlot::~frmPlot() { delete ui; } void frmPlot::initForm() { } void frmPlot::initPanel() { qDeleteAll(frms); frms.clear(); QStringList names; names << "通道A1" << "通道B1" << "通道C1" << "通道A2" << "通道B2" << "通道C2"; for (int i = 0; i < 6; i++) { frmPlotPanel *frm = new frmPlotPanel; frm->setObjectName("frmPlotPanel" + QString::number(i)); connect(frm, SIGNAL(plotPressed()), this, SLOT(plotPressed())); connect(this, SIGNAL(setMaxX(int)), frm, SLOT(setMaxX(int))); connect(this, SIGNAL(setMaxY(int)), frm, SLOT(setMaxY(int))); frm->setName(names.at(i)); frms.append(frm); } ui->widgetPanel->setAutoHeight(true); ui->widgetPanel->setAutoWidth(true); ui->widgetPanel->setMargin(6); ui->widgetPanel->setSpace(6); ui->widgetPanel->setColumnCount(3); ui->widgetPanel->setWidgets(frms); } void frmPlot::plotPressed() { frmPlotPanel *frm = (frmPlotPanel *)sender(); QString objName = frm->objectName(); if (objName.startsWith("frmPlotPanel")) { static bool max = false; int index = objName.right(1).toInt(); //将当前按下的窗体最大化 for (int i = 0; i < frms.count(); i++) { frmPlotPanel *frm = (frmPlotPanel *)frms.at(i); if (!max) { frm->setVisible(i == index); frm->setBtnHide(!(i == index)); } else { frm->setVisible(true); frm->setBtnHide(true); } } max = !max; } }