0

I have read the QStatusBar class Documentation, and it is says that removeWidget():

does not delete the widget but hides it. To add the widget again, you must call both the addWidget() and show() functions.

As per the instructions, I wrote the code below:

ui->statusbar->addWidget(ui->label);
ui->statusbar->removeWidget(ui->label);
ui->statusbar->addWidget(ui->label);
ui->statusbar->show();

I added label widget using Qt Designer.

I was Expecting that label will be added to the statusbar but it was not.

How to do I add it back to statusbar?

1 Answers1

1

You should call

ui->label->show()

instead of:

ui->statusbar->show()

As follows:

ui->statusbar->addWidget(ui->label);
ui->statusbar->removeWidget(ui->label);
ui->statusbar->addWidget(ui->label);
ui->label->show();