Skip to main content

QTagEdit

QTagEdit

A tag based edit

At a glance​

TierFree (GPLv3)
Importfrom Custom_Widgets.QCustomTagEdit import QTagEdit
Qt DesignerYes — drag it from the palette

Quick start​

from Custom_Widgets.QCustomTagEdit import QTagEdit

widget = QTagEdit()
widget.setTagSuggestions(["python", "qt", "pyside6", "pyqt5", "widgets"])
widget.setTags(["python", "qt", "pyside6", "widgets"])

That is the exact code behind the screenshot above.

Dark theme​

Colours come from the design tokens, so the widget follows the app theme with no extra work.

QTagEdit in dark theme

Properties​

Every property below is settable in code and in Qt Designer.

PropertyTypeDefault
frameShapeQFrame::Shape—
frameShadowQFrame::Shadow—
lineWidthint—
midLineWidthint—
frameWidthint—
frameRectQRect—
verticalScrollBarPolicyQt::ScrollBarPolicy—
horizontalScrollBarPolicyQt::ScrollBarPolicy—
sizeAdjustPolicyQAbstractScrollArea::SizeAdjustPolicy—
widgetResizablebool—
alignmentQFlags<Qt::AlignmentFlag>—
tagColorcolor—
tagTextColorcolor—

Methods​

MethodDescription
addTag(text: str) -> boolAdds a new tag
clear(input=True) -> NoneClears all tags
enableCheckForDoubles(check_for_doubles) -> NoneEnables if a new tag, when its going to be added, should be checked if it already exists
enableTagSuggestions(tag_suggestions: bool) -> NoneEnables whenever a new tag is typed in that suggestions from self.__tag_suggestions(...) should be showing or not.
onDoubledTag(text: str) -> NoneThis method gets called if self._check_for_doubles is True (can be set via enableCheckForDoubles(...))
removeTag(tag: str) -> NoneRemoves a tag
setTagSuggestions(suggestions: List[str]) -> NoneSets the tag suggestions. They will be used if self._tag_suggestions is True (can be set via enableTagSuggestions(...))
setTags(tags: List[str]) -> NoneReplaces all current tags with tag from the tags argument
tagColor(*args, **kwargs)Tag color.
tagTextColor(*args, **kwargs)Tag text color.
tags() -> List[str]Returns all tag names

Theming​

Colours come from the design tokens, so they follow the active theme. Roles used: on-secondary, on-surface, outline, secondary, surface.

See Design tokens.

QCustomButtonGroup · QCustomCheckBox · QCustomColorPicker · QCustomComboBox · QCustomDateEdit · QCustomDateRangeEdit · QCustomDateRangePicker · QCustomEmojiPicker