PDA

View Full Version : How to set Default Text Statement in QComboBox



rawfool
26th April 2012, 14:06
How to set a default text to QComboBox. For Eg., "Select an option", as shown below

Before :
-----------------------
|Select an option | V |
-----------------------

On Click :
-----------------------
|_____________ | V |
|Option 1 |
|Option 2 |
|Option 3 |
-----------------

sedi
26th April 2012, 19:38
Try out this:

void QComboBox::setEditText ( const QString & text )

You might have to subclass the QComboBox to achieve the deleting when the user selects, I am not sure.
Might be doable with the signals:

void editTextChanged ( const QString & text )
and/or

void activated ( int index )
void activated ( const QString & text )

I am not sure if this works, but it might be worth a try.
http://qt-project.org/doc/qt-4.8/qcombobox.html is your friend :-)