c++ - Creating object in loop dynamically -


i want create many buttons in qt within loop.

in header file:

qvector<qpushbutton> *btns; 

in cpp file:

btns = new qvector<qpushbutton>(); for(int = 0; <= 10; i++) {     btns->append(new qpushbutton(qstring::number(i),this)); } 

i'm getting error:

cannot convert argument 1 'qpushbutton *' 'const qpushbutton &'

it's not hard fix it, not pointers. can me?

in header

qvector<qpushbutton*>  btns; 

in source

for(int = 0; <= 10; i++) {    btns.append(new qpushbutton(qstring::number(i),this)); } 

Comments