Accessibility
Expose roles, names, states, and values to assistive technologies
and respond to system contrast and motion preferences.
Use the
Accessible attached properties when you need to give an icon-only button a spoken label, add a description to a control, override a default role, or read the user's system accessibility preferences.Every control in Ljós exposes an accessibility node for itself with a default
Accessible.role and Accessible.name derived from its type and text, without extra markup:Button → buttonCheckBox and CheckDelegate → checkboxRadioButton → radiobuttonSwitch and SwitchDelegate → switchLabel → labelGroupBox → group (controls inside the group box appear inside its group node in the accessibility tree)ToolBar → toolbar (buttons in the tool bar appear inside its node)A control's accessible name follows its
text or title dynamically: changing text updates the name immediately. On buttons (including check boxes and delegates), a single ampersand (&) that marks a mnemonic is stripped from the accessible name, while a doubled ampersand (&&) becomes a single &; a lone trailing & stays. Controls that are not buttons, such as Label and GroupBox, keep ampersands in their accessible name. The mnemonic letter is drawn underlined, and Alt with that letter clicks the button. Screen readers and accessibility tools can locate a control by its role and name and trigger clicks or toggle check boxes directly.You can override the defaults on any item using
Accessible attached properties, including role, name, description, focusable, focused, ignored, modal, checkable, checked, checkStateMixed, defaultButton, editable, multiLine, passwordEdit, pressed, readOnly, searchEdit, selectable, selectableText, selected, and expandable (plus Accessible.AnnouncementPoliteness values Polite and Assertive, and Accessible.Role values such as NoRole, TitleBar, MenuBar, ScrollBar, Grip, Sound, Cursor, Caret, and AlertMessage).Write this as
Main.qml and run ljos check on its directory:Here the slider reports its name as
"Volume", its value as 4 in the range 0 to 10, and its description, while the button reports "Save the document" instead of "Save".Watch out for icon-only buttons: a control with no
text has no accessible name at all, regardless of the icon it displays. Always set Accessible.name on icon-only buttons:Value and state controls keep the accessibility tree updated as the user interacts with them:
Check states: Checked, unchecked, and partially checked (
checkStateMixed) states on CheckBox and CheckDelegate are reported, along with pressed, expanded, disabled, read-only, and selected states, and the position of a ComboBox or Menu row within its set.Sliders, dials, and progress bars:
Slider, Dial, and ProgressBar report their current numeric value and range. On a RangeSlider, each handle exposes its own value and can be moved independently by an assistive technology without moving the other handle (stopping when it meets the other handle).Dialogs, popups, menus, and tool tips: While a
Dialog, Popup, Menu, or ToolTip is closed, it is absent from the accessibility tree. When a Dialog opens, it enters the tree as a dialog node named after its title, holds its child controls inside its node, and moves keyboard focus inside the dialog until it closes (a plain Popup enters as an unnamed dialog node). Activating a dialog button or MenuItem from a screen reader triggers the item and closes the dialog with its result. An open Menu is named by its title, and a visible ToolTip is named by its text.You can inspect system accessibility preferences through
Qt.styleHints.accessibility:Qt.styleHints.accessibility.contrastPreference and Qt.styleHints.accessibility.motionPreference read the system's contrast and motion settings.When reduced motion is active, movement animations jump straight to their end state (still emitting
started and finished), fades and colour transitions are capped at 150 ms, and animations that run for ever keep running.Qt.styleHints.accessibility also has fontScale and screenReaderActive, and a font has font.scaleWithSystem.The Basic style's default
palette.placeholderText (3.04:1 on white, 3.95:1 in the dark scheme) is below the 4.5:1 minimum for normal text; set palette.placeholderText when you need higher contrast. Ljos.Controls draws its placeholder role at 4.5:1 or more.




