ui->setupUi(this);
QWidget *win = new QWidget();
QVBoxLayout* lay = new QVBoxLayout(win);
lay->setAlignment(Qt::AlignTop | Qt::AlignLeft);
QPushButton *botton = new QPushButton(cmd);
lay->addWidget(botton);
ui->scrollAreaWidgetContents->setLayout(lay);
滚动区域中的数据居中对齐,并希望将其更改为左对齐从过去几天开始,我试图使数据左对齐,但它没有改变谁能在这方面帮助我
将分隔符项添加到右侧的水平布局中。
QHBoxLayout * poHLayout = new QHBoxLayout;
QPushButton * button = new QPushButton(cmd);
// Spacer item
QWidget * poSpacerItem = new QWidget(this);
poSpacerItem->setSizePolicy(
QSizePolicy::Minimum,QSizePolicy::Maximum);
// Add your button to the left side. (will align button to left)
poHLayout->addWidget(button);
// Add spacer item
poHLayout->addWidget(poSpacerItem);
ui->scrollAreaWidgetContents->setLayout(poHLayout);