Hi,
I have a question:
I have 3 item in a combo: red, green, blue.
I want to remove "blue" but I don't have any index
Hou can I remove a item in QComboBox withuot use index?
bye!
Hi,
I have a question:
I have 3 item in a combo: red, green, blue.
I want to remove "blue" but I don't have any index
Hou can I remove a item in QComboBox withuot use index?
bye!
I don't know the specifics of your situation, but I guess you could clear the combobox, and then re-insert all the items except the "blue" one. But this isn't as nice as if you had the index.
Bojan
The march of progress:
C:
printf("%10.2f", x);
C++:
cout << setw(10) << setprecision(2) << showpoint << x;
Java:
java.text.NumberFormat formatter = java.text.NumberFormat.getNumberInstance();
formatter.setMinimumFractionDigits(2);
formatter.setMaximumFractionDigits(2);
String s = formatter.format(x);
for (int i = s.length(); i < 10; i++) System.out.print(' ');
System.out.print(s);
drow (14th June 2006)
Do you mean items named "red", "green" and "blue"?Originally Posted by drow
Why don't you just search for it?
Qt Code:
// iterate through the items and find the one to be removed for (int = 0; i < combo->count(); ++i) { if (combo->text(i) == "blue") { combo->removeItem(i); break; } } // OR make use of QComboBox::setCurrentText() combo->setCurrentText("blue"); combo->removeItem(combo->currentItem());To copy to clipboard, switch view to plain text mode
J-P Nurmi
drow (14th June 2006)
I mast remove more item ( 100 - 800 item ) and this solution isn't efficentOriginally Posted by Bojan
I'll try this solutionOriginally Posted by jpn
thk's all
drow
If you have this many items, it'll be best if you store indices of all items, for example in a QHash or something like that (but you have to use the model approach with persistant indices for that).
drow (15th June 2006)
Bookmarks