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);
滚动区域中的数据居中对齐,并希望将其更改为左对齐 从过去的几天开始,我试图让数据保持一致,但不会改变 任何人都可以在这方面帮助我
答案 0 :(得分:0)
将间隔物项目添加到水平布局的右侧。
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);