I used scrollArea widget before, that time i created it in designer and to add the widgets into it i did as below

Qt Code:
  1. ui->scrollAreaWidgetContents->layout()->addWidget(checkbox);
  2. ui->scrollAreaWidgetContents->layout()->addWidget(ComboOperator);
To copy to clipboard, switch view to plain text mode 
But now i wanted to create one more scroll area programattically(without designer)
I declared as below...

Qt Code:
  1. sarea->layout()->addWidget(checkbox);
  2. sarea->layout()->addWidget(ComboOperator);
To copy to clipboard, switch view to plain text mode 


And when i tried to put inside it, program was crashing.
Here i didnt get option to use scrollAreaWidgetContents, as it was available in designer....
Please tell me what wrong here...