c++ - How to delete QLabel and QwtSlider in a std::vector -



c++ - How to delete QLabel and QwtSlider in a std::vector -

i have std::vector filled qlabel , qwtslider pointers , delete pointers not vector.

here code:

qlabel *slidersimuvarlabel; std::vector<qlabel*> labelssimuvarlist; std::vector<qwtslider*> sliderssimuvarlist; int num = 3; (int i=0; i<numsimuvars; ++i){ slidersimuvarlabel = new qlabel("hello", widg); slidersimuvarlabel->setfont(panelfont2); labelssimuvarlist.push_back(new qlabelwidg)); labelssimuvarlist[i]->setfont(panelfont2); sliderssimuvarlist.push_back(new qwtslider(qt::horizontal,widg)); layoutsimupanel->addwidget(slidersimuvarlabel,i+7,0); layoutsimupanel->addwidget(sliderssimuvarlist[i],i+7,1,1,5); layoutsimupanel->addwidget(labelssimuvarlist[i], i+7, 7); }

i don’t know method delete pointers: clear()? deletelater()? others?

to remove objects (pointers) vector , delete them can:

// remove elements while (!labelssimuvarlist.empty()) { delete labelssimuvarlist.back(); labelssimuvarlist.pop_back(); }

c++ qt vector qwt

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -