spootnx spootnx - 6 months ago 119
Python Question

How to hide QComboBox items instead of clearing them out

I can't find a way to hide

QComboBox
items. So far the only way to filter its items out is to delete the existing ones (with
.clear()
method). And then to rebuild the entire
QComboBox
again using its
.addItem()
method.

I would rather temporary hide the items. And when they are needed to unhide them back.
Is hide/unhide on QCombobox items could be accomplished?

Answer

You can use the removeItem() method to remove an item from the QComboBox.

void QComboBox::removeItem ( int index )

Removes the item at the given index from the combobox. This will update the current index if the index is removed.

This function does nothing if index is out of range.

If you don't know the index, use the findText() method.

There are no hide/unhide methods for QComboBox items.

Comments