I display the width value of the horizontalSpacer , then add the widget to the horizontalLayout , then I display the width value of the horizontalSpacer . The width of the horizontalSpacer should become smaller, but it is not updated. How to make it updated? `
void SearchForm::on_pushButton_10_clicked() { std::cout << ui->horizontalSpacer->geometry().width() << std::endl; QPushButton* PB = new QPushButton; ui->horizontalLayout->addWidget(PB); std::cout << ui->horizontalSpacer->geometry().width() << std::endl; }