CFullTestIOInWindow::CFullTestIOInWindow(QWidget *parent) : QWidget(parent) { setProperty("testFlag",0); setProperty("init",0); setProperty("in",0); cf = ((CApp*)qApp)->_tjob->_mconfig; _ioItemCount = cf->_map_ioin.size(); if(!property("init").toInt()) { setProperty("init",1); QVBoxLayout *top = new QVBoxLayout; for(int i=0; i != _ioItemCount; ++i) { QLabel *_tempLabel = new QLabel; _tempLabel->setStyleSheet("border-radius:20px;background:#fff;border:1px solid #666;"); _tempLabel->setFixedSize(40,40); _vec32IO.push_back(_tempLabel); } _testButton1 = new QPushButton(tr("检测低电平")); _testButton2 = new QPushButton(tr("检测高电平")); _statusLabel = new QLabel(tr("点击高低电平测试所有通道,点击圆圈发生检测单个通道。")); _statusLabel->setStyleSheet("font:bold 16px;color:#0099FF;max-height:26px;min-height:26px;background:#CCFF99;"); _statusLabel_1 = new QLabel(tr("当前电平为:")); _statusLabel_1->setStyleSheet("font:bold 18px;color:#0099FF;max-height:30px;min-height:30px;background:#CCFF99;"); _testButton1->setFocusPolicy(Qt::NoFocus); _testButton2->setFocusPolicy(Qt::NoFocus); _bReadCurrent = new QCheckBox("读取激励电流"); _bReadCurrent->setFocusPolicy(Qt::NoFocus); //***Layout QGroupBox *_mainGroupBox = new QGroupBox(QString::number(_ioItemCount) + tr("路IO输入量测试")); QGridLayout *_mainGridLay = new QGridLayout(_mainGroupBox); _mainGridLay->addWidget(_statusLabel,0,0,1,8); _mainGridLay->addWidget(_statusLabel_1,1,0,1,8); for(int i=0; i != _ioItemCount; ++i) { QVBoxLayout *_tempVLay = new QVBoxLayout; int kk = ((CApp*)qApp)->_tjob->getIOInMapVoltage(i); QLabel *io = new QLabel( kk?tr("高电平有效"):tr("低电平有效") ); if(kk) io->setStyleSheet("background-color:wheat;"); else io->setStyleSheet("background-color:yellow;"); _vec32IO[i]->installEventFilter(this); _tempVLay->addWidget(new QLabel("I/O量"+QString("%1").arg(i))); _tempVLay->addWidget(_vec32IO.at(i)); _tempVLay->addWidget(io); _mainGridLay->addLayout(_tempVLay,i/8+2,i%8,1,1); if( ((CApp*)qApp)->_tjob->getIOInMapCurrent(i)!=-1 ) _vec32IO[i]->setText(tr("电流")); } _mainGridLay->addWidget(_bReadCurrent,6,2,1,2); _mainGridLay->addWidget(_testButton1,6,4,1,2); _mainGridLay->addWidget(_testButton2,6,6,1,2); top->addWidget(_mainGroupBox); top->setSizeConstraint(QLayout::SetFixedSize); setLayout(top); //***Signal connect(_testButton1,SIGNAL(clicked()),this,SLOT(testButton1Clicked())); connect(_testButton2,SIGNAL(clicked()),this,SLOT(testButton2Clicked())); connect((CApp*)qApp,SIGNAL(sendBackFullTestData_ioi_485(QByteArray)),this,SLOT(sendBackData485(QByteArray))); connect((CApp*)qApp,SIGNAL(sendBackFullTestData_ioi_232(QByteArray)),this,SLOT(sendBackData232(QByteArray))); } }
void Wt_TestWidget::clickTestButton1() { printf("clickTestButton1\n"); emit testButton1Clicked(); }