Keep widget centered in QHBoxLayout after adding another widget to the edge
Solved
General and Desktop
-
QHBoxLayout *layout = new QHBoxLayout(); QLabel *label = new QLabel(); label->setText("label"); layout->addStretch(); layout->addWidget(label); layout->addStretch(); QPushButton *button = new QPushButton(); layout->addWidget(button); setMinimumSize(500,100); setLayout(layout);
If I only add a QLabel to the layout then it is centered but when I try to add a QPushButton to the right side, the label moves a bit to the left. Is there a way to keep the label in in the same position as the first image after I add the button?
-
@tjudg Perhaps you should try adding a horizontal QSpacerItem on the left side.