ZepDisplay_Qt is the Qt rendering backend for Zep. It implements the ZepDisplay interface using Qt’s QPainter API.
Header: include/zep/qt/zepdisplay_qt.h
Classes
ZepDisplay_Qt
Qt implementation of the display interface.ZepFont_Qt
Qt font wrapper usingQFont.
Implementation Details
Painter Management (zepdisplay_qt.h:111)
QPainter instance. Typically called at the start of your widget’s paintEvent().
Drawing Operations
DrawChars (zepdisplay_qt.h:116)
- Casts font to
ZepFont_Qtand applies it viaQPainter::setFont() - Sets pen color using
QColor::fromRgbF() - Uses
QPainter::drawText()withQt::TextLongestVariantflag - Adjusts vertical position to account for font descent
- Text is rendered as UTF-8 using
QString::fromUtf8()
DrawLine (zepdisplay_qt.h:133)
- Uses
QPainter::drawLine()with aQPenof specified width and color - Color is converted to
QColorviaQColor::fromRgbF()
DrawRectFilled (zepdisplay_qt.h:141)
- Uses
QPainter::fillRect()with aQRectandQColor - Converts Zep’s rect format to Qt’s
QRect
Clipping (zepdisplay_qt.h:148)
- Sets clip rect via
QPainter::setClipRect()if width > 0 - Disables clipping with
QPainter::setClipping(false)when width is 0 - Stores the current clip rect in
m_clipRect
Font Management (zepdisplay_qt.h:162)
- Creates
ZepFont_Qtinstances on demand - Uses application default font height as base
- Scales font size for heading types:
Heading1: 1.75x base heightHeading2: 1.5x base heightHeading3: 1.25x base height
Font Configuration (zepdisplay_qt.h:40)
ZepFont_Qt::SetPixelHeight() configures the font:
- Uses
"Menlo"on macOS,"Consolas"on other platforms - Sets
QFont::Monospacestyle hint - Calculates and caches font descent using
QFontMetrics - Invalidates character size cache
Text Measurement (zepdisplay_qt.h:57)
- Uses
QFontMetrics::size()with flags:Qt::TextIncludeTrailingSpacesQt::TextLongestVariant
- Handles tab characters by multiplying width by 4
- Falls back to ‘A’ character size for invalid glyphs
- Returns width and height as
NVec2f
Helper Functions
The header provides conversion utilities:Usage Example
Platform Differences
- macOS: Uses Menlo font by default
- Other platforms: Uses Consolas font by default
- Both fall back to Qt’s generic monospace font if the preferred font is unavailable
Related
- ZepDisplay - Abstract display interface
- ZepDisplay_ImGui - ImGui implementation
