PDA

View Full Version : Set Default text in QCombo box



daarsh
11th April 2011, 08:16
Hi,
I want to create a combo box so that it has some default text and whenever an item is selected form dropdown menu the item gets appended to default text.
something like this

|------------------|--|
|SEX: MALE |V |
!________________!__|
MALE
FEMALE

so when i click FEMALE it should look like

|------------------|--|
|SEX: FEMALE |V |
!________________!__|
MALE
FEMALE

viulskiez
11th April 2011, 10:24
I guess there is no simple way to do that. Unlike QSpinBox and QDoubleSpinBox, QComboBox doesn't have a method such setPrefix or setSuffix.
In model-view convenience, it is possible to customize the data. In this case, what you have to do is creating the model, modifying the data and specify how it displayed through the model.

high_flyer
11th April 2011, 10:38
Just create a slot which you connect to one of the signals that signal itme selection, and in that slot change the contents of the first element in such that it will include the text of the current selected item.