pyqt_reactive.widgets.shared.tear_off_tab_widget

TearOffTabWidget - Chrome-style detachable tabs for PyQt6.

Allows users to drag tabs out to create floating windows, and drag them into other windows to dock them.

Classes

FloatingTabWindow(content_widget, title, ...)

Floating window for torn-off tabs.

FloatingWindowDragState([start_pos, active])

Drag-state projection for a floating torn-off tab window.

TabDragData(source_widget, tab_index, ...)

Data container for tab drag operations.

TearOffTabBar([parent])

Custom tab bar that supports tear-off drag operations.

TearOffTabWidget([parent])

QTabWidget with Chrome-style tear-off tab support.

class pyqt_reactive.widgets.shared.tear_off_tab_widget.FloatingWindowDragState(start_pos: QPoint | None = None, active: bool = False)[source]

Drag-state projection for a floating torn-off tab window.

start_pos: QPoint | None
active: bool
classmethod begin(start_pos: QPoint) FloatingWindowDragState[source]
activate_if_threshold_met(current_pos: QPoint, threshold: int) FloatingWindowDragState[source]
moved_to(current_pos: QPoint) FloatingWindowDragState[source]
__init__(start_pos: QPoint | None = None, active: bool = False) None
class pyqt_reactive.widgets.shared.tear_off_tab_widget.TabDragData(source_widget: TearOffTabWidget, tab_index: int, tab_text: str, tab_widget: QWidget)[source]

Data container for tab drag operations.

__init__(source_widget: TearOffTabWidget, tab_index: int, tab_text: str, tab_widget: QWidget)[source]
class pyqt_reactive.widgets.shared.tear_off_tab_widget.TearOffTabBar(parent=None)[source]

Custom tab bar that supports tear-off drag operations.

tab_tear_off_requested

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

__init__(parent=None)[source]
mousePressEvent(event)[source]

Track initial click position for drag detection.

mouseMoveEvent(event)[source]

Detect drag-out for tear-off.

mouseReleaseEvent(event)[source]

Reset drag tracking.

class pyqt_reactive.widgets.shared.tear_off_tab_widget.TearOffTabWidget(parent=None)[source]

QTabWidget with Chrome-style tear-off tab support.

Allows dragging tabs out to create floating windows, and dragging them into other TearOffTabWidgets to dock.

Features: - Drag tab out to create floating window - Drag tab into another TearOffTabWidget to dock - Visual feedback during drag (preview pixmap) - Automatic cleanup of empty floating windows

Usage:

tab_widget = TearOffTabWidget() tab_widget.addTab(widget, “Tab 1”) tab_widget.addTab(widget2, “Tab 2”)

# Optional: Set callback when tab is torn off tab_widget.on_tab_torn_off = lambda tab_widget, tab_text: print(f”Torn off: {tab_text}”)

tab_torn_off

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

tab_docked

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

__init__(parent=None)[source]
on_tab_torn_off: Callable[[QWidget, str], None] | None
on_tab_docked: Callable[[QWidget, str, int], None] | None
dragEnterEvent(event)[source]

Accept drag from other tear-off tabs.

dragMoveEvent(event)[source]

Update drop indicator position.

dragLeaveEvent(event)[source]

Hide drop indicator.

dropEvent(event)[source]

Handle tab drop from another window.

closeEvent(event)[source]

Unregister from registry when closed.

class pyqt_reactive.widgets.shared.tear_off_tab_widget.FloatingTabWindow(content_widget: QWidget, title: str, source_tab_widget: TearOffTabWidget, parent=None)[source]

Floating window for torn-off tabs.

Contains a single tab’s content and can be dragged to dock into other TearOffTabWidgets.

__init__(content_widget: QWidget, title: str, source_tab_widget: TearOffTabWidget, parent=None)[source]
mousePressEvent(event)[source]

Start tracking for window drag.

mouseMoveEvent(event)[source]

Handle window dragging and check for dock targets.

mouseReleaseEvent(event)[source]

Handle drop - dock if over a target.

closeEvent(event)[source]

Handle window close - return tab to source if not docked.