其他分享
首页 > 其他分享> > QT::控件类4

QT::控件类4

作者:互联网

 

QHBoxLayout横向布局
//向布局中添加控件 
hboxLayout->addWidget(button1); 
hboxLayout->addWidget(button2); 
hboxLayout->addWidget(button3);
//间隔 
hboxLayout->setSpacing(60);
//实例QWidget 
widget = new QWidget(); 
//绑定布局 
widget->setLayout(hboxLayout); 
//绑定界面 
this->setCentralWidget(widget);

 

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);
//实例QWidget 
widget = new QWidget();
//绑定布局 
widget->setLayout(gridLayout); 
//绑定界面 
this->setCentralWidget(widget);

 



 

标签:控件,widget,QT,gridLayout,hboxLayout,QWidget,addWidget,new
来源: https://www.cnblogs.com/osbreak/p/14342465.html