I tried to create a list of buttons using for loop as follow:
Qt Code:
  1. Mywidget::Mywidget()
  2. {
  3. QVBoxLayout *h_layout=new QVBoxLayout(this);
  4. QPushButton *close_button=new QPushButton[4];
  5. for (int i = 0; i < 5; ++i) {
  6. close_button[i]=new QPushButton("Close",this);
  7. h_layout->addWidget(close_button);
  8. }
  9. }
To copy to clipboard, switch view to plain text mode 
But the following error appears:
Qt Code:
  1. error: no match for 'operator=' (operand types are 'QPushButton' and 'QPushButton*')close_button[i]=new QPushButton("Close",this);
  2. ^
To copy to clipboard, switch view to plain text mode 
But if i removed
Qt Code:
  1. close_button[i]
To copy to clipboard, switch view to plain text mode 
and make it only
Qt Code:
  1. close_button
To copy to clipboard, switch view to plain text mode 
it create the required button, but the problem here that i can not use every pointer to do specific thing for example :
Qt Code:
  1. connect(close_button[2],SIGNAL(clicked(bool)),qApp,SLOT(quit()));
To copy to clipboard, switch view to plain text mode 
Please help