#include "buglayoutsubwindow.h"

bugLayoutSubWindow::bugLayoutSubWindow(QWidget *parent, Qt::WFlags flags)
	: QMainWindow(parent, flags)
{
	ui.setupUi(this);

	/*create widget of subWindow*/
	m_widget = new QWidget(0);
	/*create any layout (vertical) in temp widget (of subWindow)*/
	QVBoxLayout * layout=new QVBoxLayout(m_widget);

	/*add widgets to layout*/
	m_tabWidget =new QTabWidget(m_widget);
	layout->addWidget(m_tabWidget);
	m_pushButton = new QPushButton("add tab", m_widget);
	layout->addWidget(m_pushButton);
	
	m_widget->setLayout(layout);
	/*set widget into subWindow*/
	ui.mdiArea->addSubWindow(m_widget);
	/*signal-slot for create new tab in subWindow*/
	connect(m_pushButton,SIGNAL(clicked()),this,SLOT(addTab()));
}

bugLayoutSubWindow::~bugLayoutSubWindow()
{

}

void bugLayoutSubWindow::addTab()
{	
	/*create widget into 'new' tab*/
	QWidget	*widget = new QWidget(m_tabWidget);

	/*create any layout (vertical) into 'new' tab's widget*/
 	QVBoxLayout * layout=new QVBoxLayout(widget);

	/*add widgets to layout*/
 	QPushButton *pushButton = new QPushButton("verify layout", widget);
	layout->addWidget(pushButton);

	widget->setLayout(layout);

	/*add new tab - set widget with layout*/
	m_tabWidget->addTab(widget,"new tab");

	/* bug - layout don`t resize subwindow when tab was added. but when I resize subWindow, layout resized subWindow automatically (layout 'setMinimumSize' for subWindow)*/
}
