combo_box ========= .. py:module:: qfluentwidgets.components.widgets.combo_box Module Contents --------------- .. autoapisummary:: qfluentwidgets.components.widgets.combo_box.ComboItem qfluentwidgets.components.widgets.combo_box.ComboBoxBase qfluentwidgets.components.widgets.combo_box.ComboBox qfluentwidgets.components.widgets.combo_box.EditableComboBox qfluentwidgets.components.widgets.combo_box.ComboBoxMenu .. py:class:: ComboItem(text: str, icon: Union[str, PyQt5.QtGui.QIcon, qfluentwidgets.common.icon.FluentIconBase] = None, userData=None, isEnabled=True) Combo box item .. py:attribute:: text .. py:attribute:: userData :value: None .. py:property:: icon .. py:attribute:: isEnabled :value: True .. py:class:: ComboBoxBase(parent=None, **kwargs) Bases: :py:obj:`PyQt5.QtCore.QObject` Combo box base .. py:attribute:: currentIndexChanged .. py:attribute:: currentTextChanged .. py:attribute:: activated .. py:attribute:: textActivated .. py:attribute:: isHover :value: False .. py:attribute:: isPressed :value: False .. py:attribute:: items :type: List[ComboItem] :value: [] .. py:attribute:: dropMenu :value: None .. py:method:: eventFilter(obj, e: PyQt5.QtCore.QEvent) .. py:method:: addItem(text: str, icon: Union[str, PyQt5.QtGui.QIcon, qfluentwidgets.common.icon.FluentIconBase] = None, userData=None) add item Parameters ---------- text: str the text of item icon: str | QIcon | FluentIconBase .. py:method:: addItems(texts: Iterable[str]) add items Parameters ---------- text: Iterable[str] the text of item .. py:method:: removeItem(index: int) Removes the item at the given index from the combobox. This will update the current index if the index is removed. .. py:method:: currentIndex() .. py:method:: setCurrentIndex(index: int) set current index Parameters ---------- index: int current index .. py:method:: setText(text: str) .. py:method:: currentText() .. py:method:: currentData() .. py:method:: setCurrentText(text) set the current text displayed in combo box, text should be in the item list Parameters ---------- text: str text displayed in combo box .. py:method:: setItemText(index: int, text: str) set the text of item Parameters ---------- index: int the index of item text: str new text of item .. py:method:: itemData(index: int) Returns the data in the given index .. py:method:: itemText(index: int) Returns the text in the given index .. py:method:: itemIcon(index: int) Returns the icon in the given index .. py:method:: setItemData(index: int, value) Sets the data role for the item on the given index .. py:method:: setItemIcon(index: int, icon: Union[str, PyQt5.QtGui.QIcon, qfluentwidgets.common.icon.FluentIconBase]) Sets the data role for the item on the given index .. py:method:: setItemEnabled(index: int, isEnabled: bool) Sets the enabled status of the item on the given index .. py:method:: findData(data) Returns the index of the item containing the given data, otherwise returns -1 .. py:method:: findText(text: str) Returns the index of the item containing the given text; otherwise returns -1. .. py:method:: clear() Clears the combobox, removing all items. .. py:method:: count() Returns the number of items in the combobox .. py:method:: insertItem(index: int, text: str, icon: Union[str, PyQt5.QtGui.QIcon, qfluentwidgets.common.icon.FluentIconBase] = None, userData=None) Inserts item into the combobox at the given index. .. py:method:: insertItems(index: int, texts: Iterable[str]) Inserts items into the combobox, starting at the index specified. .. py:method:: setMaxVisibleItems(num: int) .. py:method:: maxVisibleItems() .. py:class:: ComboBox(parent=None) Bases: :py:obj:`PyQt5.QtWidgets.QPushButton`, :py:obj:`ComboBoxBase` Combo box .. py:attribute:: currentIndexChanged .. py:attribute:: currentTextChanged .. py:attribute:: activated .. py:attribute:: textActivated .. py:attribute:: arrowAni .. py:method:: setPlaceholderText(text: str) .. py:method:: setCurrentIndex(index: int) set current index Parameters ---------- index: int current index .. py:method:: mouseReleaseEvent(e) .. py:method:: paintEvent(e) .. py:class:: EditableComboBox(parent=None) Bases: :py:obj:`qfluentwidgets.components.widgets.line_edit.LineEdit`, :py:obj:`ComboBoxBase` Editable combo box .. py:attribute:: currentIndexChanged .. py:attribute:: currentTextChanged .. py:attribute:: activated .. py:attribute:: textActivated .. py:attribute:: dropButton .. py:method:: setCompleterMenu(menu) set completer menu Parameters ---------- menu: CompleterMenu completer menu .. py:method:: currentText() .. py:method:: setCurrentIndex(index: int) set current index Parameters ---------- index: int current index .. py:method:: clear() Clears the combobox, removing all items. .. py:method:: setPlaceholderText(text: str) .. py:class:: ComboBoxMenu(parent=None) Bases: :py:obj:`qfluentwidgets.components.widgets.menu.RoundMenu` Combo box menu .. py:method:: exec(pos, ani=True, aniType=MenuAnimationType.DROP_DOWN) show menu Parameters ---------- pos: QPoint pop-up position ani: bool Whether to show pop-up animation aniType: MenuAnimationType menu animation type