mak_user
29th March 2011, 02:55
I want to make child widgets re-sizable along with the parent. Could you help me ?
This is my widget constructor:
CustomWidget::CustomWidget(QWidget *parent) :
QWidget(parent)
{
m_button_edit.setText(tr("Edit"));
m_button_all.setText(tr("All"));
m_button_cancel.setText(tr("Cancel"));
InitializeModels();
m_table1 = new QTableView(this);
m_table2 = new QTableView(this);
SetTables();
QSplitter *splitter = new QSplitter(Qt::Vertical, this);
splitter->addWidget(m_table1);
QWidget *temp = new QWidget(this);
QGridLayout *layout_table2 = new QGridLayout(this);
layout_table2->addWidget(m_table2, 0, 0, 1, 3);
layout_table2->addWidget(&m_button_edit, 1, 0, 1, 1);
layout_table2->addWidget(&m_button_all, 1, 1, 1, 1);
layout_table2->addWidget(&m_button_cancel, 1, 2, 1, 1);
temp->setLayout(layout_table2);
splitter->addWidget(temp);
}
I got some small window which I should stretch to see the items inside and they have a fixed size.
If you have any other suggestion about better approach in setting widget positions than in my case I would be glad if you share.
This is my widget constructor:
CustomWidget::CustomWidget(QWidget *parent) :
QWidget(parent)
{
m_button_edit.setText(tr("Edit"));
m_button_all.setText(tr("All"));
m_button_cancel.setText(tr("Cancel"));
InitializeModels();
m_table1 = new QTableView(this);
m_table2 = new QTableView(this);
SetTables();
QSplitter *splitter = new QSplitter(Qt::Vertical, this);
splitter->addWidget(m_table1);
QWidget *temp = new QWidget(this);
QGridLayout *layout_table2 = new QGridLayout(this);
layout_table2->addWidget(m_table2, 0, 0, 1, 3);
layout_table2->addWidget(&m_button_edit, 1, 0, 1, 1);
layout_table2->addWidget(&m_button_all, 1, 1, 1, 1);
layout_table2->addWidget(&m_button_cancel, 1, 2, 1, 1);
temp->setLayout(layout_table2);
splitter->addWidget(temp);
}
I got some small window which I should stretch to see the items inside and they have a fixed size.
If you have any other suggestion about better approach in setting widget positions than in my case I would be glad if you share.