I am trying to put some spinboxes,line edits in a layout. But the size extends more than the neccesity. Below is the figure
I think you should try with void setSizeConstraint ( SizeConstraint ) and minimumSize() inherited methods.
void setSizeConstraint ( SizeConstraint )
minimumSize()
Read the doc