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:
{
Q_OBJECT
public:
~A();
virtual int heightForWidth ( int w ) const { return w*535/1645;}
private:
Ui::A *ui;
B* header_widget;
C* body_widget;
void setMainLayout();
};
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();
};
To copy to clipboard, switch view to plain text mode
A.cpp:
{
ui->setupUi(this);
setMainLayout();
this->setLayout(main_layout);
}
A::~A()
{
delete ui;
}
void A::setMainLayout(){
header_widget = new B(this);
body_widget = new C(this);
main_layout->addWidget(B);
main_layout->addWidget(C);
}
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);
}
To copy to clipboard, switch view to plain text mode
B.h:
{
Q_OBJECT
public:
~B();
virtual int heightForWidth ( int w ) const { return w*535/1645;}
private:
Ui::B *ui;
};
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;
};
To copy to clipboard, switch view to plain text mode
C.h:
{
Q_OBJECT
public:
~C();
virtual int heightForWidth ( int w ) const { return w*535/1645;}
private:
Ui::C *ui;
A *widgetParent;
};
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;
};
To copy to clipboard, switch view to plain text mode
Bookmarks