#include <QApplication>
#include <QWidget>
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
#include <QResizeEvent>

class MyWidget: public QLabel
{
public:
	MyWidget(QWidget* parent = NULL);
	~MyWidget();

protected:
	void resizeEvent(QResizeEvent*);
};


MyWidget::MyWidget(QWidget* parent):
	QLabel(parent)
{
}

MyWidget::~MyWidget()
{
}

void MyWidget::resizeEvent(QResizeEvent* e)
{
	if (e->size().height() != 100)
		resize(e->size().width(), 100);
}

int main(int argc, char* argv[])
{
	QApplication app(argc, argv);
	
	QPushButton* b1 = new QPushButton();
	b1->setText("Button 1");
	QPushButton* b2 = new QPushButton();
	b2->setText("Button 2");

	MyWidget* w1 = new MyWidget();
	w1->setText("This wont't resize");
	w1->resize(200,100);

	QVBoxLayout* hb = new QVBoxLayout();
	hb->addWidget(b1);
	hb->addWidget(w1);
	hb->addWidget(b2);

	QWidget* w = new QWidget();
	w->setLayout(hb);
	w->show();

	MyWidget* w2 = new MyWidget();
	w2->setText("This wont't resize");
	w2->resize(200,100);
	w2->show();

	return app.exec();
}
