Need help on setting up Defult text on QCombo box
Dear friends,
I need Help on how to set default text to be displayed on combo box before selecting an item from it, i used the following code,
Code:
cmb.addinsertItem(-1,"Select text");
cmb.additem("abcdef");
cmb->setCurrentIndex(-1);
but the "Select Text" is not displayed on the combo box by defualt, instead it is displayed as one of the item in the combo box drop down list.....
can any one help me to solve this,
Thanks in advance,
Re: Need help on setting up Defult text on QCombo box
-1 is the value when no item is set. Make the current Index to '0'. And also make the 'Select Text' item index as '0' too.
Re: Need help on setting up Defult text on QCombo box
s thanks for your response nikhilqt
i dont want to add it as an item in the combo box. is it possible to set "Select Text" as default till i select an item from combo?
Re: Need help on setting up Defult text on QCombo box
That's what i am saying. It's your logic to do that. Check out the signals of QComboBox like currentIndexChanged(...), activated(...). On slots put your logic such that the 'Select Text' would be default option if no item is selected. Once selected remove that item from the combobox list.