123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- #include "dialogselect.h"
- #include "ui_dialogselect.h"
- #include <QGroupBox>
- #include <QScrollArea>
- DialogSelect::DialogSelect(std::vector<std::string> xvectorlist, std::vector<std::string> &xvectorused,QWidget *parent) :
- QDialog(parent),
- ui(new Ui::DialogSelect)
- {
- ui->setupUi(this);
- mpvectorused = &xvectorused;
- QGroupBox * pGroup = new QGroupBox();
- pGroup->setGeometry(50,100,560,3000);
- QScrollArea * pScroll = new QScrollArea(this);
- pScroll->setWidget(pGroup);
- pScroll->setGeometry(30,100,600,300);
- int ntotalwidth = 560;
- int ncheckwidth = 80;
- int ncheckheight = 23;
- int nhospace = 100;
- int nvespace = 30;
- unsigned int i;
- int ipos = 0;
- int jpos = 0;
- for(i=0;i<xvectorlist.size();i++)
- {
- QCheckBox * pcheck = new QCheckBox(pGroup);
- pcheck->setGeometry(30+ipos*nhospace,30+jpos*nvespace,ncheckwidth,ncheckheight);
- pcheck->setText(xvectorlist[i].data());
- mvectorcheck.push_back(pcheck);
- unsigned int j;
- bool bused = false;
- for(j=0;j<xvectorused.size();j++)
- {
- if(xvectorused[j] == xvectorlist[i])
- {
- bused = true;
- break;
- }
- }
- pcheck->setChecked(bused);
- ipos++;
- if(ipos>=((ntotalwidth -30)/nhospace))
- {
- ipos = 0;
- jpos++;
- }
- }
- setWindowTitle("Select Chart Item");
- }
- DialogSelect::~DialogSelect()
- {
- delete ui;
- }
- void DialogSelect::on_pushButton_Select_clicked()
- {
- mpvectorused->clear();
- unsigned int i;
- for(i=0;i<mvectorcheck.size();i++)
- {
- if(mvectorcheck[i]->isChecked())
- {
- mpvectorused->push_back(mvectorcheck[i]->text().toStdString());
- }
- }
- this->accept();
- }
|