simple adding lable into QVBoxLayout layout does not resize label .

Qt Code:
  1. QLabel *label = new QLabel("test");
  2. QVBoxLayout *layout = new QVBoxLayout;
  3. QWidget *widget = new QWidget;
  4. widget->setLayout(layout);
  5. layout->addWidget(label);
To copy to clipboard, switch view to plain text mode 

But when I add QTabWidget it resizes just fine.

I have tried this scenario using Q Designer and works there.

I have tried changing different sizePolicy of the label and widget, no luck.

what I am doing wrong ??