![](http://static.javashuo.com/static/loading.gif)
#include <QApplication>
![](http://static.javashuo.com/static/loading.gif)
#include <QPushButton>
![](http://static.javashuo.com/static/loading.gif)
#include <QFont>
![](http://static.javashuo.com/static/loading.gif)
#include <QGridLayout>
![](http://static.javashuo.com/static/loading.gif)
#include
"lcdrange.h"
![](http://static.javashuo.com/static/loading.gif)
#include
"mywidget.h"
//MyWidget類實現部分
![](http://static.javashuo.com/static/loading.gif)
MyWidget::MyWidget(QWidget *parent)
![](http://static.javashuo.com/static/loading.gif)
: QWidget(parent)
![](http://static.javashuo.com/static/loading.gif)
{
//建立quit按鈕
![](http://static.javashuo.com/static/loading.gif)
QPushButton *quit =
new QPushButton(tr(
"Quit"));
![](http://static.javashuo.com/static/loading.gif)
quit->setFont(QFont(
"Times", 18, QFont::Bold));
![](http://static.javashuo.com/static/loading.gif)
connect(quit, SIGNAL(clicked()), qApp, SLOT(quit()));
//網格佈局
![](http://static.javashuo.com/static/loading.gif)
QGridLayout *grid =
new QGridLayout;
for (
int row = 0; row < 3; ++row) {
for (
int column = 0; column < 3; ++column) {
![](http://static.javashuo.com/static/loading.gif)
LCDRange *lcdRange =
new LCDRange;
//建立LCD+Slider
![](http://static.javashuo.com/static/loading.gif)
grid->addWidget(lcdRange, row, column);
![](http://static.javashuo.com/static/loading.gif)
}
![](http://static.javashuo.com/static/loading.gif)
}
![](http://static.javashuo.com/static/loading.gif)
QVBoxLayout *layout =
new QVBoxLayout;
![](http://static.javashuo.com/static/loading.gif)
layout->addWidget(quit);
![](http://static.javashuo.com/static/loading.gif)
layout->addLayout(grid);
//子佈局
![](http://static.javashuo.com/static/loading.gif)
setLayout(layout);
//設置佈局
![](http://static.javashuo.com/static/loading.gif)
}