Hi all,
I have created a custom widget, A, which I assign as the central widget.
In its constructor I create and assign to it two other custom widgets - B and C.
in A's constructor I put B and C inside a QVBoxLayout and add this layout to widget A.

When I run the application and resize the window the B widget resizes properly but the C widget does not.
I am attaching the redacted .h files and constructors of all these widgets.

Any help will be appreciated.

A.h:
Qt Code:
  1. class A : public QWidget
  2. {
  3. Q_OBJECT
  4.  
  5. public:
  6. explicit A(QWidget *parent = 0);
  7. ~A();
  8. virtual int heightForWidth ( int w ) const { return w*535/1645;}
  9.  
  10. private:
  11. Ui::A *ui;
  12. B* header_widget;
  13. C* body_widget;
  14. QVBoxLayout* main_layout;
  15. void setMainLayout();
  16. };
To copy to clipboard, switch view to plain text mode 

A.cpp:
Qt Code:
  1. A::A(QWidget *parent) : QWidget(parent), ui(new Ui::A)
  2. {
  3. ui->setupUi(this);
  4. setMainLayout();
  5. this->setLayout(main_layout);
  6. }
  7.  
  8. A::~A()
  9. {
  10. delete ui;
  11. }
  12.  
  13.  
  14. void A::setMainLayout(){
  15. main_layout = new QVBoxLayout();
  16.  
  17. header_widget = new B(this);
  18. body_widget = new C(this);
  19.  
  20. main_layout->addWidget(B);
  21. main_layout->addWidget(C);
  22. }
To copy to clipboard, switch view to plain text mode 

B.h:
Qt Code:
  1. class B : public QWidget
  2. {
  3. Q_OBJECT
  4.  
  5. public:
  6. explicit B(QWidget *parent = 0);
  7. ~B();
  8. virtual int heightForWidth ( int w ) const { return w*535/1645;}
  9.  
  10.  
  11. private:
  12. Ui::B *ui;
  13. };
To copy to clipboard, switch view to plain text mode 

C.h:
Qt Code:
  1. class C : public QStackedWidget
  2. {
  3. Q_OBJECT
  4.  
  5. public:
  6. explicit C(QWidget *parent = 0);
  7. ~C();
  8. virtual int heightForWidth ( int w ) const { return w*535/1645;}
  9.  
  10. private:
  11. Ui::C *ui;
  12. A *widgetParent;
  13. };
To copy to clipboard, switch view to plain text mode