c++ - How to access widgets created within functions in later function calls in Qt -


so have code, in c++, creates few qlabels, qlineedit, , qcheckbox when selection made qcombobox. however, able access widgets have created in later function destroy them if new selection made combo box. able access objects created using designer doing ui->object not able objects created using own code. can how, because know how work that.

in short, able dynamically create/destroy qwidgets based on selections made user. there reference should know of this, or documentation? or going wrong way? here code presently have creating objects:

   if (eventtype == qstring::fromstdstring("birthday"))    {     qlabel *label1 = new qlabel ("celebrant: ");    qlabel *label2 = new qlabel ("surprise: ");    qlineedit *lineedit = new qlineedit;    qcheckbox *box = new qcheckbox;     ui->gridlayout->addwidget(label1,3,0,1,1, 0);    ui->gridlayout->addwidget(label2,4,0,1,1,0);    ui->gridlayout->addwidget(lineedit,3,1,1,1,0);    ui->gridlayout->addwidget(box,4,1,1,2,0);     } 

if give them names (using setobjectname()) can find them later using qobject::findchildren().

but wouldn't easier store them in member variables?


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -