*sigh*
You really should first learn basic syntax and basic concepts of what is an array, and containers of C++.

Qt Code:
  1. Mywidget::Mywidget()
  2. {
  3. QVBoxLayout *h_layout=new QVBoxLayout(this);
  4. for (int i = 0; i < 5; ++i) {
  5. QPushButton* pButton = new QPushButton("Close",this);
  6. h_layout->addWidget(pButton);
  7. }
  8. }
To copy to clipboard, switch view to plain text mode