c++ - how to get the name of a button created by QDialogButtonBox? -
i'm trying button child widgets of window. buttons created through qdialogbuttonbox. how 1 cancel/ok/save button?
i have:
qwidget *pwin = qapplication::activewindow(); qlist<qpushbutton *> allpbuttons = pwin->findchildren<qpushbutton *>(); qlistiterator<qpushbutton*> i(allpbuttons); while( i.hasnext() ) { //identify button cancel/ok/save button here /*note: i'm having trouble, getting text of button here returns null. other way of identifying which? special case when buttons created through qdialogbuttonbox? */ }
you should use qdialogbuttonbox::button() method, button of corresponding role.
for instance :
qpushbutton* pokbutton = pbuttonbox->button(qdialogbuttonbox::ok); qpushbutton* pcancelbutton = pbuttonbox->button(qdialogbuttonbox::cancel); // , on...
generally speaking, it's bad idea find button it's text, text might change when app internationalized.
Comments
Post a Comment