How to change just one item of QCombobox editable by the user
Unsolved
General and Desktop
-
i have 4 items in my QCombobox,
'Bryce king' 'James White' 'Russo W' 'Custom Manager'
so when i click on
'Custom Manager',
it should change to editable and i must be able to enter my own desired name.
i have tried to achieve this behavior using Qtcreator, and in the properties, i can set it to editable but that would make all items editable instead of just 1.
-
Hi
Editable is for all items then.
It cant handle only one being editable as its not the design.The normal use case for this would be to have it nonedible and then have
'Add Custom Manager'
Then when you select that, it shows a QInputDialog allowing users to enter a name and press ok to have that added to the listed and selected as the current one.
That said something like this does work ok-ish
void MainWindow::on_comboBox_currentIndexChanged(int index) { if (index == ui->comboBox->count()-1) ui->comboBox->setEditable(true); else ui->comboBox->setEditable(false); }