MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
this->setWindowTitle("HapticChip");
QDesktopWidget * desktop=QApplication::desktop();
auto screen= desktop->screenNumber(this);
QRect rect=desktop->screenGeometry(screen);
this->move((rect.width()-this->width())/2,(rect.height()-this->height())/2);
QToolBar* toolBar=new QToolBar(this);
toolBar->setAllowedAreas(Qt::TopToolBarArea);//设置工具栏的停靠区域
toolBar->setMovable(false);//设置工具栏的可移动性
chipNameCB=new QComboBox();
chipNameCB->addItem("SIA86917");
chipNameCB->addItem("SIA86927");
chipNameCB->addItem("SIH6887");
chipNameCB->setCurrentIndex(0);
toolBar->addWidget(chipNameCB);
//添加分割线到工具栏中
toolBar->addSeparator();
//将工具栏对象添加到主窗口中
this->addToolBar(toolBar);
//创建一个widget设置为主窗体的CentralWidget
mainWidget =new QWidget();
this->setCentralWidget(mainWidget);
//创建一个Layout,并把Layout添加到CentralWidget中
QStackedLayout* layout=new QStackedLayout();
layout->setMargin(5);
this->centralWidget()->setLayout(layout);
QWidget* SIA86917=new QWidget();
QHBoxLayout* hLayout =new QHBoxLayout();
SIA86917->setLayout(hLayout);
hLayout->setDirection(QBoxLayout::LeftToRight);
hLayout->setMargin(5);
hLayout->addWidget(new QPushButton("SIA86917"),1);
hLayout->addWidget(new QPushButton("SIA86917"),2);
hLayout->addWidget(new QPushButton("SIA86917"),3);
hLayout->addWidget(new QPushButton("SIA86917"),4);
hLayout->addStretch(1);
layout->addWidget(SIA86917);
QWidget* SIA86927=new QWidget();
QGridLayout* gLayout=new QGridLayout();
SIA86927->setLayout(gLayout);
gLayout->addWidget(new QPushButton("SIA86927"),0,0);
gLayout->addWidget(new QPushButton("SIA86927"),0,2);
gLayout->addWidget(new QPushButton("SIA86927"),2,0);
gLayout->addWidget(new QPushButton("SIA86927"),2,2);
gLayout->addWidget(new QPushButton("SIA86927"),0,1,1,3);
layout->addWidget(SIA86927);
QWidget* SIH6887=new QWidget();
QFormLayout* fLayout=new QFormLayout();
fLayout->setRowWrapPolicy(QFormLayout::DontWrapRows);
SIH6887->setLayout(fLayout);
fLayout->addRow("111",new QPushButton("SIH6887"));
fLayout->addRow("222",new QPushButton("SIH6887"));
fLayout->addRow("333",new QPushButton("SIH6887"));
layout->addWidget(SIH6887);
connect(chipNameCB,SIGNAL(currentIndexChanged(int)),layout,SLOT(setCurrentIndex(int)));
}


