QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(button1); layout->addWidget(button2); layout->setSpacing(10);
QGridLayout *layout = new QGridLayout; layout->addWidget(label1, 0, 0); layout->addWidget(editBox1, 0, 1); layout->addWidget(label2, 1, 0); layout->addWidget(editBox2, 1, 1); layout->setSpacing(20);This code defines a grid layout with two rows and two columns. It adds two labels and two edit boxes to the layout and sets the spacing between each widget to be 20 pixels. The package library for QLayout setSpacing is the Qt C++ library.