..... {
resize(500,200);
/*控件定义*/
TitleLayout = new QGridLayout;
/*编号1*/
SettingBtn = new QPushButton(tr("设置"));
TitleLable = new QLabel(tr("小胖出品"));
TypeChooseBtn = new QPushButton(tr("风格选择"));
/*编号2*/
TitleLayout->addWidget(SettingBtn,0,0);
TitleLayout->addWidget(TitleLable,0,2);
TitleLayout->addWidget(TypeChooseBtn,0,4);
PrintCodeLabel = new QLabel(tr("输入打印码:"));
PrintCodeLineEdit = new QLineEdit;
OneBtn = new QPushButton(tr("1"));
TwoBtn = new QPushButton(tr("2"));
ThreeBtn = new QPushButton(tr("3"));
FourBtn = new QPushButton(tr("4"));
FiveBtn = new QPushButton(tr("5"));
SixBtn = new QPushButton(tr("6"));
SevenBtn = new QPushButton(tr("7"));
EightBtn = new QPushButton(tr("8"));
NineBtn = new QPushButton(tr("9"));
ZoreBtn = new QPushButton(tr("0"));
OkBtn = new QPushButton(tr("确定"));
RightLayout = new QGridLayout;
RightLayout->addWidget(PrintCodeLabel,0,0,1,2);
RightLayout->addWidget(PrintCodeLineEdit,1,0,1,2);
RightLayout->addWidget(OneBtn,2,0);
RightLayout->addWidget(TwoBtn,2,1);
RightLayout->addWidget(ThreeBtn,2,2);
RightLayout->addWidget(FourBtn,3,0);
RightLayout->addWidget(FiveBtn,3,1);
RightLayout->addWidget(SixBtn,3,2);
RightLayout->addWidget(SevenBtn,4,0);
RightLayout->addWidget(EightBtn,4,1);
RightLayout->addWidget(NineBtn,4,2);
RightLayout->addWidget(ZoreBtn,5,0);
RightLayout->addWidget(OkBtn,5,1);
ShowLabel = new QLabel(tr("welcome!"));
LeftLayout = new QGridLayout;
LeftLayout->addWidget(ShowLabel);
BodyLayout = new QHBoxLayout;
BodyLayout->addLayout(LeftLayout);
BodyLayout->addLayout(RightLayout);
MainLayout = new QVBoxLayout;
MainLayout->addLayout(TitleLayout);
MainLayout->addLayout(BodyLayout);
setLayout(MainLayout);
} ...注意布局如果网格布局的控件new成垂直布局那就出现上述情况了。