only some of the widgets are resizing properly
-
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:
class A : public QWidget { Q_OBJECT public: explicit A(QWidget *parent = 0); ~A(); virtual int heightForWidth ( int w ) const { return w*535/1645;} private: Ui::A *ui; B* header_widget; C* body_widget; QVBoxLayout* main_layout; void setMainLayout(); };
A.cpp:
A::A(QWidget *parent) : QWidget(parent), ui(new Ui::A) { ui->setupUi(this); setMainLayout(); this->setLayout(main_layout); } A::~A() { delete ui; } void A::setMainLayout(){ main_layout = new QVBoxLayout(); header_widget = new B(this); body_widget = new C(this); main_layout->addWidget(B); main_layout->addWidget(C); }
B.h:
class B : public QWidget { Q_OBJECT public: explicit B(QWidget *parent = 0); ~B(); virtual int heightForWidth ( int w ) const { return w*535/1645;} private: Ui::B *ui; };
C.h:
class C : public QStackedWidget { Q_OBJECT public: explicit C(QWidget *parent = 0); ~C(); virtual int heightForWidth ( int w ) const { return w*535/1645;} private: Ui::C *ui; A *widgetParent; };