#include "runchwiget.h" #include "ui_runchwiget.h" #include "pdu_ctrl.h" #include #include RunChWiget::RunChWiget(QWidget *parent) : QWidget(parent), ui(new Ui::RunChWiget), SaveIndex(0) { ui->setupUi(this); //setRunCh(); ui->scrollAreaWidgetContents->SetScrollBar(ui->scrollArea->horizontalScrollBar(),ui->scrollArea->verticalScrollBar()); connect(ui->pushButton,&QPushButton::clicked,this,&RunChWiget::slot_ALLCHCtrl); } RunChWiget::~RunChWiget() { delete ui; } void RunChWiget::setRunCh() { GlobalPowerCtrlBoard* pAllChData=nullptr; int nSize=pdu_Ctrl::instance()->getPowerBoard(pAllChData); if(!pAllChData||nSize==SaveIndex) { return; } qDebug()<<"CHUpdate:Size="<gridLayout->addWidget(pCHWidget,nSize/2,nSize%2); m_vecChWidget.push_back(pCHWidget); } void RunChWiget::initScrollArea() { // 启用触控手势 QScroller::grabGesture(ui->scrollArea->viewport(), QScroller::TouchGesture); // 获取滚动控制器 QScroller* scroller = QScroller::scroller(ui->scrollArea); // 配置滚动参数 QScrollerProperties prop = scroller->scrollerProperties(); // 设置滚动摩擦系数(值越小惯性越长) prop.setScrollMetric(QScrollerProperties::DragVelocitySmoothingFactor, 0.6); prop.setScrollMetric(QScrollerProperties::MinimumVelocity, 0.0); prop.setScrollMetric(QScrollerProperties::MaximumVelocity, 0.5); prop.setScrollMetric(QScrollerProperties::SnapPositionRatio, 0.2); prop.setScrollMetric(QScrollerProperties::DragStartDistance, 0.001); scroller->setScrollerProperties(prop); // 设置视口必须接受触摸事件 ui->scrollArea->viewport()->setAttribute(Qt::WA_AcceptTouchEvents); } void RunChWiget::slot_CtrlCH(int nIndex) { WarningWnd pCtrlBox(this); pCtrlBox.SetCHID(nIndex); //connect(pCtrlBox,SIGNAL(signals_CHCtrl(int,int)),this,SLOT()); pCtrlBox.setModal(true); pCtrlBox.exec(); } void RunChWiget::slot_ALLCHCtrl() { WarningWnd pCtrlBox(this); pCtrlBox.SetCHID(0); //connect(pCtrlBox,SIGNAL(signals_CHCtrl(int,int)),this,SLOT()); pCtrlBox.setModal(true); pCtrlBox.exec(); }