Skip to content

UniDeskComboBox Type

Dropdown control based on UniDeskButton. Integrates UniDeskMenu as the popup list, supporting editable mode, font delegate rendering, and component delegate rendering.

ItemDescription
Control TypeVisual Control
Source FileUniDesk/Controls/UniDeskComboBox.qml
InheritsUniDeskButton
QML Importimport UniDesk.Controls 1.0

Custom Properties

PropertyTypeDefaultDescription
enableFontDelegateboolfalseEnable font delegate mode (renders each item's text as a font name)
enableComDelegateboolfalseEnable component delegate mode (for editor highlighting)
comManagervarComponent manager reference
currentIndexint0Current selected index
modelvar[]List of options
editableboolfalseWhether the text field is editable
displayTextstringmodel[currentIndex]Display text (non-editable mode)
editTextstringdisplayTextEdit text (editable mode)
currentTextstringCurrent text (read-only, returns displayText or editText depending on mode)
inputMethodHintsintQt.ImhNoPredictiveTextInput method hints
validatorvarnullInput validator
selectTextByMouseboolfalseWhether text can be selected by mouse

Signals

signal activated()

Emitted when the user triggers a selection (menu click or edit completion match).

Behavior

  • Clicking the button automatically opens the UniDeskMenu popup
  • The menu automatically pops up or down depending on available space
  • enableFontDelegate mode renders menu items using their text as font names (used by font pickers)
  • enableComDelegate mode links menu item highlighting to component indicated state
  • In editable mode, pressing Enter after typing automatically matches an option in model
  • Inherits all properties from UniDeskButton (colors, radius, icon, etc.)

Examples

qml
import UniDesk.Controls 1.0

// Basic usage
UniDeskComboBox {
    model: ["Option A", "Option B", "Option C"]
    currentIndex: 0
    onActivated: console.log("selected:", currentText)
}

// Editable mode
UniDeskComboBox {
    model: ["Beijing", "Shanghai", "Guangzhou"]
    editable: true
    onActivated: console.log("confirmed:", currentText)
}

// Font delegate mode
UniDeskComboBox {
    model: ["Microsoft YaHei", "SimSun", "KaiTi"]
    enableFontDelegate: true
}

Released under the CC BY-SA 4.0 open documentation license.