A modern, animated, and highly customizable Qt ComboBox, built on top of TextField.
This component replaces QComboBox with a fully custom popup, smooth animations, icon support, and dark-mode awareness.
- Custom dropdown popup (no native QComboBox)
- Smooth fade-in / fade-out animation
- Built on top of TextField
- Editable & non-editable modes
- Icon + text items (Iconic mode)
- Automatic dark mode synchronization
- Smart popup positioning (above / below / center)
- Max visible item control
- Custom item delegate
- Custom scrollbars
- Auto-complete with
QCompleter - Auto close on outside click or app deactivation
| Part | Implementation |
|---|---|
| Base class | TextField |
| Popup container | RoundedBox |
| Item view | QListView |
| Data model | QStandardItemModel |
| Animation | QPropertyAnimation + SmoothOpacity |
| Delegate | Custom Delegate |
| Scrollbars | Custom ScrollBar |
ComboBox *box = new ComboBox(this);
box->setPlaceholderText("Select an option");
box->addItems({"Apple", "Banana", "Mango"});box->addItems(QStringList{
"Item One",
"Item Two",
"Item Three"
});box->setIconic(true);
box->addItems({"Home", "Settings", "Profile"});
box->addIcons(
{":/icons/light/home.svg", ":/icons/light/settings.svg", ":/icons/light/user.svg"},
{":/icons/dark/home.svg", ":/icons/dark/settings.svg", ":/icons/dark/user.svg"}
);Important
setIconic(true) must be enabled before adding icons.
box->setEditable(true);- User can type directly
- Inline auto-completion enabled
- Press Enter to select a matching item
- Context menu and text selection enabled
Note
When it is disabled, all text interaction is blocked.
box->setDarkMode(true);box->setMaxVisibleItems(6);Note
By default, its value is 8
box->setPlaceholderText("Select an option");Displays hint text when:
- No item is selected
- The ComboBox text is empty The placeholder behaves exactly like a QLineEdit placeholder and is inherited from TextField.
- Fade-in when opening
- Fade-out when closing
- Uses QPropertyAnimation
- Popup closes automatically on:
- Outside click
- Application deactivation
- Item selection No manual animation handling required.
Popup placement is calculated dynamically:
- Centered (preferred)
- Below the ComboBox
- Above the ComboBox Also:
- Respects screen boundaries
- Works on multi-monitor setups
- Prevents clipping
int index = box->currentIndex();
QString text = box->currentText();Programmatic Selection
box->setCurrentItem(2);box->deleteItem(1);box->clearAll();