c++ - Qt - Set display text of non-editable QComboBox -


i set text of qcombobox custom text (that not in qcombobox's list), without adding text item of qcombobox. behaviour achievable on editable qcombobox qcombobox::setedittext(const qstring & text). on non-editable qcombobox, however, function nothing.

is possible programmatically set display/edit text of non-editable qcombobox not in list? or have find way (e.g. use qpushbutton popup menu)

edit: consider editable qcombobox insertpolicy qcombobox::noinsert. if user types in , hits enter, entered value used not added list. want behaviour change 'current' text programmatically, without allowing user type in text himself. user can choose qcombobox, time later, may want override 'current' text.

i had same problem when subclassed qcombobox make combo box of check boxes. wrote small function programmatically change text displayed in combo box, didn't want enable user edit text. solution set combo box editable:

 this->seteditable(true); 

and qcombobox::lineedit() read only. refer function:

void checkedcombobox::settext(qstring text) {    qlineedit *displayedtext = this->lineedit();    displayedtext->settext(text);    displayedtext->setreadonly(true); } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -