I have a few questions about frames.
Here is a test program I have been experimenting with

Qt Code:
  1. class BuildGui : public QMainApplication
  2. {
  3. public:
  4. BuildGui(QWidget* parent = 0);
  5. private:
  6. QWidget* makeWidget(QString text);
  7.  
  8. QVBoxLayout* layout;
  9. };
  10.  
  11. BuildGui::BuildGui(QWidget* parent = 0) : QMainApplication(parent)
  12. {
  13. QWidget* w1 = makeWidget("Ex 1");
  14. QWidget* w2 = makeWidget("Ex 2");
  15.  
  16. layout = new QVBoxLayout;
  17. layout->addWidget(w1);
  18. layout->addWidget(w2);
  19.  
  20. QWidget* cw = new QWidget;
  21. cw->setLayout(layout);
  22.  
  23. sa->setWidget(cw);
  24.  
  25. setCentralWidget(sa);
  26. }
  27.  
  28. QWidget* BuildGui::makeWidget(QString text)
  29. {
  30. QLineEdit* le = new QLineEdit(text);
  31. return le;
  32. }
To copy to clipboard, switch view to plain text mode 

which works as expected - I see the 2 text boxes one above the other with "Ex 1" and "Ex 2" for the text.

Now I add this method:
Qt Code:
  1. QWidget* BuildGui::addFrame(QWidget w)
  2. {
  3. QFrame* f = new QFrame;
  4. f->setFrameStyle(QFrame::Box);
  5. w->setParent(f);
  6. return f;
  7. }
To copy to clipboard, switch view to plain text mode 

and modify the constructor:
Qt Code:
  1. QWidget* f1 = addFrame(sc1);
  2. ...
  3. // layout->setWidget(w1);
  4. layout->setWidget(f1);
To copy to clipboard, switch view to plain text mode 

now the "Ex 1" box does not show up. If I add
Qt Code:
  1. f1->setMinimumSize(50,50);
To copy to clipboard, switch view to plain text mode 
then it is visible.
So my question is
Can i make the frame automatically adjust to the size of the widget it is framing?

Thanks,
Steve

PS I know some widgets have a setFrame() method but I want this to work for framinh any widget.