Module slint::docs::cargo_features
source Β· Expand description
Feature flags and backend selection.
Use the following feature flags in your Cargo.toml to enable additional features.
-
compat-1-2
(enabled by default) β Mandatory feature: This feature is required to keep the compatibility with Slint 1.2 Newer patch version may put current functionality behind a new feature that would be enabled by default only if this feature was added. More info in this blog post -
std
(enabled by default) β Enable use of the Rust standard library. -
gettext
β Enable the translations using gettextthe
@tr(...)
code from .slint files will be transformed into call todgettext
with the crate name as domain nametranslations must be enabled with the
init_translations!
macro -
libm
β This feature enables floating point arithmetic emulation using the libm crate. Use this in MCU environments where the processor does not support floating point arithmetic. -
log
β If enabled, calls ofdebug()
in.slint
files use to thelog::debug!()
macro of the log crate instead of justprintln!()
. -
serde
β Implement theserde::Serialize
andserde::Deserialize
for some of the base types such asSharedString
andSharedVector
. -
software-renderer-systemfonts
β This feature enables the software renderer to pick up fonts from the operating system for text rendering. -
unsafe-single-threaded
β Slint uses internally somethread_local
state.When the
std
feature is enabled, Slint can usestd::thread_local!
, but when in a#![no_std]
environment, we need a replacement. Using this feature, Slint will just use static variable disregarding Rustβs Send and Sync safetySafety : You must ensure that there is only one single thread that call into the Slint API
-
accessibility
(enabled by default) β Enable integration with operating system provided accessibility APIsEnabling this feature will try to expose the tree of UI elements to OS provided accessibility APIs to support screen readers and other assistive technologies.
Backends
Slint needs a backend that will act as liaison between Slint and the OS.
By default, Slint will use the Qt backend, if Qt is installed, otherwise, it
will use Winit with Femtovg.
Both backends are compiled in. If you want to not compile one of these you need
to disable the default feature and re-enable one backend. It is also possible
to use Slint without backend if you provide the platform abstraction yourself
with platform::set_platform()
.
If you enable the Winit backend, you need to also include a renderer.
renderer-femtovg
is the only stable renderer, the other ones are experimental
It is also possible to select the backend and renderer at runtime when several
are enabled, using the SLINT_BACKEND
environment variable.
SLINT_BACKEND=Qt
selects the Qt backendSLINT_BACKEND=winit
selects the winit backendSLINT_BACKEND=winit-femtovg
selects the winit backend with the femtovg rendererSLINT_BACKEND=winit-skia
selects the winit backend with the skia rendererSLINT_BACKEND=winit-software
selects the winit backend with the software renderer
If the selected backend is not available, the default will be used.
Here are the cargo features controlling the backend:
-
backend-qt
(enabled by default) β The Qt backend feature uses Qt for the windowing system integration and rendering. This backend also provides thenative
style. It requires Qt 5.15 or later to be installed. If Qt is not installed, the backend will not be operational -
backend-winit
(enabled by default) β The winit crate is used for the event loop and windowing system integration. It supports Windows, macOS, web browsers, X11 and Wayland. X11 and wayland are only available when compiling for Linux or other Unix-like operating systems. With this feature, both X11 and Wayland are supported. For a smaller build, omit this feature and select one of the other specificbackend-winit-XX
features. -
backend-winit-x11
β Simliar tobackend-winit
this enables the winit based event loop but only with support for the X Window System on Unix. -
backend-winit-wayland
β Simliar tobackend-winit
this enables the winit based event loop but only with support for the Wayland window system on Unix. -
renderer-femtovg
(enabled by default) β Render using the femtovg crate. -
renderer-skia
β Render using Skia. -
renderer-skia-opengl
β Same asrenderer-skia
, but Skia will always use OpenGL. -
renderer-skia-vulkan
β Same asrenderer-skia
, but Skia will always use Vulkan. -
renderer-software
(enabled by default) β Render using the software renderer. -
backend-linuxkms
β KMS with Vulkan or EGL and libinput on Linux are used to render the application in full screen mode, without any windowing system. (Experimental)
More information about the backends is available in the Slint Documentation