Font Edit Panel¶
DAFontEditPannelWidget provides a complete font editing panel, including font selection, font size, bold/italic/underline toggles, and font color.
Preview¶

The upper part is the default two-row layout (family/size on one row, bold/italic/underline plus color on the next); the lower part uses SingleRowLayout, which fits height-constrained toolbars. The bottom line is a live preview using the selected font and color.
Key Features¶
- ✅ Font selection: QFontComboBox
- ✅ Font size: QSpinBox
- ✅ Style toggles: Bold, italic, underline
- ✅ Font color: DAColorPickerButton integration
- ✅ Per-item preview (optional): dropdown rows render in the current size/style, off by default
- ✅ Recent fonts (optional): a host-injected 5-entry entry point, absent by default
- ✅ Signal notification:
currentFontChanged,currentFontColorChanged
Usage¶
1. Basic Usage¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
2. Signal Handling¶
1 2 3 4 5 6 7 8 9 10 11 | |
3. Font Weight¶
1 2 | |
Qt5/Qt6 Weight Enum
QFont::Weight was redefined between Qt5 and Qt6. In Qt5, the enum uses QFont::Light, QFont::Normal, QFont::DemiBold, QFont::Bold, QFont::Black. In Qt6, weight is an integer (0–1000) with named constants like QFont::Medium. DAWidgets handles this difference internally — always use the setFontWeight() API rather than directly manipulating the QFont.
Font Preview and Recent Families¶

1. Enabling Per-item Preview¶
1 | |
- Each row of the font dropdown is rendered with "its own family + the panel's current size (clamped to 9–20pt) / bold / italic / underline".
- Only the popup list is affected: the collapsed text,
sizeHint(),minimumSizeHint()and toolbar height stay the same. When turned off, the delegate is restored to Qt's native font delegate, pixel-identical to the default. - Row height grows with the font size but is clamped to twice the base row height, so a 48pt row cannot push the popup off screen.
- Families that are not installed (a host history may point at an uninstalled font) fall back to the panel font instead of rendering a row of boxes.
2. Recent Fonts¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
- A non-empty list shows the clock button next to the font dropdown; menu rows render in their own family, and choosing one changes only the family — the current point size is preserved.
- An empty list hides the button and leaves
sizeHint()as if the feature did not exist. - The library does not append automatically and never writes
QSettings; persistence and timing are entirely the host's responsibility.
Core Properties & Methods¶
| Method | Description |
|---|---|
getCurrentFont() / setCurrentFont(QFont) |
Get/set the font |
getCurrentFontColor() / setCurrentFontColor(QColor) |
Get/set the font color |
getFontWeight() / setFontWeight(QFont::Weight) |
Get/set the font weight |
setFontPreviewEnabled(bool) / isFontPreviewEnabled() |
Per-item dropdown preview (default off) |
setMaxRecentFontCount(int) / maxRecentFontCount() |
Recent-font cap (default 5, 1–20) |
setRecentFontFamilies(QStringList) / recentFontFamilies() |
Recent families (newest first, deduplicated, capped) |