Ok, here goes. This is the simplified version which represents the problem.

main.cpp
Qt Code:
  1. #include <QApplication>
  2. #include "a.h"
  3.  
  4. int main(int argc, char *argv[]){
  5.  
  6. QApplication app(argc, argv);
  7.  
  8. A a;
  9. a.show();
  10.  
  11. return app.exec();
  12. }
To copy to clipboard, switch view to plain text mode 

a.h
Qt Code:
  1. #ifndef A_H
  2. #define A_H
  3.  
  4. #include <QWidget>
  5. #include <QPushButton>
  6. #include <QVBoxLayout>
  7. #include <QApplication>
  8. #include <qDebug>
  9.  
  10. class A : public QWidget
  11. {
  12. Q_OBJECT
  13. public:
  14. A();
  15. void changeButtonText();
  16.  
  17. public slots:
  18. void buttonPressed();
  19. private:
  20. QPushButton *button;
  21. QVBoxLayout *layout;
  22. };
  23.  
  24. #endif
To copy to clipboard, switch view to plain text mode 

a.cpp
Qt Code:
  1. #include "a.h"
  2. #include "b.h"
  3.  
  4. A::A()
  5. {
  6. layout = new QVBoxLayout();
  7. setLayout(layout);
  8. button = new QPushButton(tr("try"));
  9. connect(button,SIGNAL(clicked()),this,SLOT(buttonPressed()));
  10.  
  11. layout->addWidget(button);
  12. }
  13.  
  14. void A::buttonPressed()
  15. {
  16. B *ObjectB;
  17. ObjectB = new B;
  18. }
  19.  
  20. void A::changeButtonText()
  21. {
  22. button->setText(tr("here"));
  23. QApplication::processEvents();
  24. qDebug(button->text().toLocal8Bit());
  25. }
To copy to clipboard, switch view to plain text mode 

b.h
Qt Code:
  1. #ifndef B_H
  2. #define B_H
  3.  
  4. #include "a.h"
  5.  
  6. class B : public A
  7. {
  8. Q_OBJECT
  9. public:
  10. B();
  11. };
  12.  
  13. #endif
To copy to clipboard, switch view to plain text mode 

b.cpp
Qt Code:
  1. #include "b.h"
  2.  
  3. B::B()
  4. {
  5. changeButtonText();
  6. }
To copy to clipboard, switch view to plain text mode 

Test.pro
Qt Code:
  1. TEMPLATE = app
  2. CONFIG += qt warn_on embed_manifest_exe console
  3. QT += network
  4. TARGET = Test
  5. SOURCES = main.cpp a.cpp b.cpp
  6. HEADERS = a.h b.h
  7. LIBS +=
  8.  
  9.  
  10. # Treat warnings as errors
  11. win32:QMAKE_CXXFLAGS += /WX
  12.  
  13. CONFIG(debug, debug|release){
  14. # Debug build options
  15. # Enable a read-only console window (i.e. for printf etc.)
  16. # CONFIG += console
  17. }
  18. else{
  19. # Release build options
  20. # Enable a read-only console window (i.e. for printf etc.)
  21. # CONFIG += console
  22. }
To copy to clipboard, switch view to plain text mode