Item Selection & Preview¶
This family targets "pick a few entries from a candidate set" and "preview an entry style": a checkable list, an item-pick dialog, a selected-item list editor, a plain string-list editor, and a color-scale preview bar. They only understand DAItemEntry (display text + identifying data) or plain strings, so they carry no business semantics and fit column pickers, field pickers, module paths, tool allow-lists, and similar scenarios.
Preview¶

The most common combination: selected entries are listed with an inline remove button, the Add arrow opens a candidate menu while the body opens the pick dialog, and Up/Down buttons reorder rows without drag and drop.
DAItemEntry¶
DAItemEntry is the shared data structure for all item-selection widgets:
1 2 3 4 5 | |
When candidates may have duplicate names (for example duplicate column headers), put the real identity (column index, field name, ...) in data to avoid ambiguity.
DACheckListWidget¶

A checkable list with a search box. Filtering only hides rows and never changes check state; Select All touches only currently visible, checkable, non-forced entries.
1 2 3 4 5 6 7 8 9 10 11 | |
Forced and disabled entries¶

A sub-agent tool allow-list is a typical example: the built-in save_project tool must always stay enabled, so setEntryForcedChecked() forces it on and setEntryEnabled(false) grays it out; the user cannot uncheck it.
1 2 3 | |
Keyboard Range Selection¶
1 | |
- Shift+click: using the most recent user click as the anchor, every "visible + checkable + non-forced + enabled" entry between the anchor and the target row (inclusive) gets the anchor row's current state (checked or unchecked); the whole range emits
checkedEntriesChanged()once. - Ctrl+A: when the list/view has focus, the same as clicking "Select All" — only currently visible entries are checked. When the search box has focus, Ctrl+A still selects its text.
- Off by default; while off the widget behaves exactly as before. The anchor is reset when the filter changes, on
setItems(), and when the switch is turned off, so ranges never span different filters. - Forced /
setEntryEnabled(false)/setEntryCheckable(false)entries are skipped by a range and keep their existing state.
Core methods¶
| Method | Description |
|---|---|
setItems(QVector<DAItemEntry>) |
Set candidates (no signal) |
checkedEntries() |
Checked entries (including filtered-out, disabled, and forced) |
setEntryForcedChecked(e, bool) |
Force checked; the user cannot uncheck it |
setEntryEnabled(e, bool) |
Entry availability |
setEntryCheckable(e, bool) |
Whether the entry shows a checkbox |
setSearchVisible(bool) / setSelectAllVisible(bool) / setInvertVisible(bool) |
Toggle search and action buttons |
setKeyboardSelectionEnabled(bool) / keyboardSelectionEnabled() |
Shift range selection + Ctrl+A visible select-all (default off) |
DAItemListPickDialog¶

DAItemListPickDialog is the dialog shell around DACheckListWidget, suitable for "check a batch of entries, then confirm":
1 2 3 4 5 6 7 8 9 | |
It ships with Select All / Invert Selection and OK / Cancel; filtering never loses check state.
DAItemListEditWidget¶


The "selected items" editor: every row has an inline remove button, the Add arrow opens a candidate menu while the body opens DAItemListPickDialog, and Remove All asks for confirmation with a QMessageBox by default. setReorderEnabled(true) shows Up/Down buttons; setDragReorderEnabled(true) adds handle drag-and-drop, and both can be on at the same time.
1 2 3 4 5 6 7 8 9 | |
Drag reordering and filtering¶
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
- All three switches are off by default; without them the layout and behavior are unchanged (
Remove Allstill shows the confirmation dialog). - Dragging only passes the source row number and reuses the same move logic, so row widgets and
DAItemEntry::datasurvive; dropping back at the same position emits nothing. - Filtering matches like
DACheckListWidget: trimmed, case-insensitive substring; it only hides rows, andselectedItems()always returns everything. - With no entries, or when filtering hides everything,
emptyTextis shown and the list is hidden (the empty state is not a placeholder item). orderChangedonly means reordering; the first clear click only changes the label and reverts after the timeout.setSelectedItems()also disarms it.
Core methods¶
| Method | Description |
|---|---|
setAvailableItems(QVector<DAItemEntry>) |
Candidate source for the add menu/dialog |
setSelectedItems(QVector<DAItemEntry>) |
Replace selection (no signal) |
selectedItems() |
Get selected entries in list order |
setReorderEnabled(bool) |
Show Up/Down buttons |
setDragReorderEnabled(bool) |
Handle drag reordering (default off) |
setFilterVisible(bool) |
Show the top filter box (default off) |
setEmptyText(QString) |
Empty-state text |
setConfirmClearEnabled(bool) |
Two-click clear instead of QMessageBox (default off) |
setConfirmClearInterval(int) |
Armed-state timeout in milliseconds |
orderChanged(QVector<DAItemEntry>) |
Order-changed signal (add/remove still uses selectedItemsChanged) |
setAddButtonText() / setRemoveAllButtonText() |
Override texts for i18n |
DAStringListEditWidget¶

A plain QStringList editor with two add behaviors:
AddMode::Inline: Add appends an empty editable row and starts editing;AddMode::External: Add only emitsaddRequested(), and the caller decides what to append (for example open a directory picker, then callappendItem()).
1 2 3 4 5 6 7 8 9 10 | |
Core methods¶
| Method | Description |
|---|---|
setItems(QStringList) / items() |
Replace / get the whole list |
appendItem(QString) |
Append one item (used with addRequested) |
setAddMode(AddMode) |
Inline / External |
setReorderEnabled(bool) / setRemoveEnabled(bool) |
Show Up/Down and Remove buttons |
setEditable(bool) / setMaxCount(int) / setPlaceholderText(QString) |
Editing, limit, and empty-state text |
DAColorScalePreviewWidget¶

A preview bar for conditional-formatting color scales: two colors produce a start-to-end linear gradient, three colors place the middle color at 0.5, and any other count or an invalid color renders the blank state.
1 2 3 4 5 6 | |
References¶
- DACollapse
- DAPropertyItemWidget
- Example path:
examples/all_widgets_demo(Item Selection tab)