I have two classes: class A and B. class A inherits QWidget and class B inherits class A.

When a button is clicked, it connects to a slot in class A that creates an object of class B.
After the http request is done in class B, it executes a function from the base class that changes the text of the button.

Everything runs except the button doesn't update at all. qDebug shows the label as the new text but on GUI, it is still displaying the old text. I tried update() and repaint() but none works.

Qt Code:
  1. class A : public QWidget
  2. {
  3. Q_OBJECT
  4. public:
  5. A();
  6. void clickPressed();
  7. private slots:
  8. void changeButtonText();
  9. private:
  10. QPushButton *button;
  11. };
  12.  
  13. A::A()
  14. {
  15. button = new QPushButton(tr("Hello"));
  16. connect(button,SIGNAL(clicked()),this,SLOT(clickPressed()));
  17. }
  18.  
  19. void A::changeButtonText()
  20. {
  21. button->setText(tr("again"));
  22. }
  23.  
  24. void A::clickPressed()
  25. {
  26. B *objectB = new B;
  27. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. class B : public A
  2. {
  3. Q_OBJECT
  4. public:
  5. B();
  6. private slots:
  7. void requestDone();
  8. private:
  9. QHttp *http;
  10. };
  11.  
  12. B::B()
  13. {
  14. http = new QHttp(this);
  15. ....
  16. connect(http,SIGNAL(done(bool)),this,SLOT(requestDone(bool)));
  17. }
  18.  
  19. B::requestDone(bool error)
  20. {
  21. ...
  22. changeButtonText();
  23. }
To copy to clipboard, switch view to plain text mode 

I wrote the above as an example to my problem.