布局
1.0 QHBoxLayout 水平显示布局
hboxLayout->addWidget(button1);
hboxLayout->addWidget(button2);
hboxLayout->addWidget(button3);
hboxLayout->setSpacing(60);
widget = new QWidget();
widget->setLayout(hboxLayout);
this->setCentralWidget(widget);
1.1 QVBoxLayout 垂直显示布局
vboxLayout->addWidget(button1);
vboxLayout->addWidget(button2);
vboxLayout->addWidget(button3);
vboxLayout->setSpacing(60);
widget = new QWidget();
widget->setLayout(vboxLayout);
this->setCentralWidget(widget);
1.2 QGridLayout网格布局
gridLayout = new QGridLayout();
button1 = new QPushButton("按钮1");
button2 = new QPushButton("按钮2");
button3 = new QPushButton("按钮3");
gridLayout->addWidget(button1,0,0,1,1);
gridLayout->addWidget(button2,0,1,1,1);
gridLayout->addWidget(button3,1,0,1,1);
widget = new QWidget();
widget->setLayout(gridLayout);
this->setCentralWidget(widget);
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步