1 #include "dashboard.h" 2 #include "ui_dashboard.h" 3 #include <QDesktopWidget> dashBoard(QWidget * parent)4dashBoard::dashBoard(QWidget *parent) : 5 QDialog(parent), 6 ui(new Ui::dashBoard) 7 { 8 ui->setupUi(this); 9 // int w,h; 10 // w=(1024-this->width())/2; 11 // h=(600-this->height())/2; 12 // this->mapToParent(QPoint(w,h)); 13 FormInCenter(); 14 myspeed=new mySpeed(); 15 ui->scrollArea->setWidget(myspeed); 16 connect(ui->pushButton,SIGNAL(clicked()),SLOT(on_returnButton_clicked())); 17 } FormInCenter()18void dashBoard::FormInCenter() 19 { 20 int frmX = this->width(); 21 int frmY = this->height(); 22 QDesktopWidget w; 23 int deskWidth = w.width(); 24 int deskHeight = w.height(); 25 QPoint movePoint(deskWidth / 2 - frmX / 2, deskHeight / 2 - frmY / 2); 26 this->move(movePoint); 27 } ~dashBoard()28dashBoard::~dashBoard() 29 { 30 delete ui; 31 } on_returnButton_clicked()32void dashBoard::on_returnButton_clicked() 33 { 34 this->close(); 35 } 36