iblqt.widgets.SlideToggle

class iblqt.widgets.SlideToggle[source]

Bases: QAbstractButton

A sliding toggle switch.

Adapted from Switch class by Stefan Scherfke https://stackoverflow.com/a/51825815

__init__(parent=None, height=20)[source]

Initialize the toggle switch.

Parameters:
  • parent (QWidget or None, optional) – The parent widget of the switch. Defaults to None.

  • height (int, optional) – The height of the switch in pixels. The overall size and internal geometry are derived from this value. Defaults to 20.

Return type:

None

paintEvent(event)[source]

Handle the painting of the custom toggle switch.

The appearance adapts to the widget’s enabled/disabled state and palette.

Parameters:

event (QPaintEvent) – The paint event that triggered this repaint.

sizeHint()[source]

Return the recommended size for the widget.

Returns:

The recommended size of the widget as a QSize object

Return type:

QSize