Skip to content

Native QtWidgets

shadcn-qt can apply the classic new-york + Zinc profile to an existing QtWidgets application without replacing its widget classes. The compatibility layer is opt-in, continuously adopts widgets created later, and is reversible.

python
from shadcn_qt import (
    apply_theme,
    configure_high_dpi,
    enable_native_widget_styling,
)
from shadcn_qt._qt import QtWidgets

configure_high_dpi()
app = QtWidgets.QApplication([])
enable_native_widget_styling(app)
apply_theme(app, "light")

Coverage

FamilyExamplesAdaptation
ActionsQPushButton, QCommandLinkButton, QToolButton, QDialogButtonBoxnew-york geometry, semantic variants, states, elevation
ChoicesQCheckBox, QRadioButtonantialiased check/radio glyphs, focus and disabled states
EditorsQLineEdit, QTextEdit, QKeySequenceEdit, SpinBox and date/time editorsinput geometry, validation, focus, themed arrows
SelectionQComboBox, QFontComboBox, QSlider, QDial, QScrollBarthemed controls, tracks, handles, popups, arrows
DataList, Tree, Table, Column, Header and Calendar widgetsselection hierarchy, headers, scrollbars, compact calendar delegate
ContainersChrome-style TabPane/QTabWidget, ToolBox, StackedWidget, GroupBox, Splitter, ScrollArea, GraphicsView, MDIdocument-tab states, borders, surfaces, disclosure states, handles
Window chromeQMenuBar, QMenu, QToolBar, QStatusBar, QDockWidgetthemed menus, actions, separators and dock controls
DialogsQDialog, QMessageBox, QFileDialog, QWizard and related classesthemed Qt-owned surfaces and child controls
Fallbackuncommon and third-party QWidget subclassesneutral background and foreground tokens

Every adopted widget receives shadcn_qt_component and nativeKind dynamic properties. Existing explicit properties win, allowing semantic overrides without subclassing.

Reversible enhancements

Some official shapes cannot be expressed reliably in QSS. The adapter uses an application event filter to paint checkbox/radio indicators and installs a calendar delegate, themed editor arrows, and subtle elevation where needed. disable_native_widget_styling(app) restores the original calendar delegate, removes adapter glyphs/effects, and clears only unchanged adapter defaults.

Set shadcn_qt_native_styling=False on custom-painted or third-party controls that should remain untouched.

The Gallery has a dedicated Native QtWidgets navigation group:

  • Native Forms
  • Native Data Views
  • Native Containers
  • Native Window Chrome

These pages use stock Qt classes rather than shadcn-qt component subclasses. Open one directly:

bash
python examples/python_gallery/run.py --component "Native Data Views" --theme dark

Eight light/dark screenshots are committed under packages/python/tests/baselines/native_gallery. Regenerate and verify them:

bash
python tools/update_native_gallery_baselines.py
pytest -q packages/python/tests/test_native_gallery_screenshots.py

The regression test uses downsampled perceptual comparison to tolerate minor font rasterization differences while still catching layout, palette, missing control, and large state regressions.

Platform boundaries

OS-native file/color/font dialog implementations and platform window decorations can remain under operating-system control. Select Qt's non-native dialog implementation when the entire dialog must follow the theme. Qt Quick/QML, web content, OpenGL/RHI scenes, and third-party controls that replace painting require their own theming APIs.