QT——代码添加弹簧,QSpacerItem
QWidget *w=new QWidget(this); w->setGeometry(0,0,500,80); QHBoxLayout *layout=new QHBoxLayout; QPushButton *button1=new QPushButton; QPushButton *button2=new QPushButton; QPushButton *button3=new QPushButton; layout->addWidget(button1); layout->addWidget(button2); layout->addStretch();/* 这里表示弹簧*/ layout->addWidget(button3); w->setLayout(layout);