c++ - QComboBox - set selected item based on the item's data -


what best way of selecting item in qt combo box out of prefined list of enum based unique values.

in past have become accustomed .net's style of selection item can selected setting selected property item's value wish select:

cboexample.selectedvalue = 2; 

is there anyway qt based on item's data, if data c++ enumeration?

you lookup value of data finddata , use setcurrentindex

qcombobox* combo = new qcombobox; combo->additem("100",100.0);    // 2nd parameter can qt type combo->additem .....  float value=100.0; int index = combo->finddata(value); if ( index != -1 ) { // -1 not found    combo->setcurrentindex(index); } 

Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -