diff --git a/docs/_macros.py b/docs/_macros.py index 8c5e862..5c65c55 100644 --- a/docs/_macros.py +++ b/docs/_macros.py @@ -35,7 +35,7 @@ def define_env(env: "MacrosPlugin"): src = src.replace( "QApplication([])", "QApplication.instance() or QApplication([])" ) - src = src.replace("app.exec_()", "") + src = src.replace("app.exec_()", "app.processEvents()") exec(src) _grab(dest, width) @@ -127,7 +127,6 @@ def define_env(env: "MacrosPlugin"): def _grab(dest: str | Path, width) -> list[Path]: """Grab the top widgets of the application.""" - from qtpy.QtCore import QTimer from qtpy.QtWidgets import QApplication w = QApplication.topLevelWidgets()[-1] @@ -135,12 +134,3 @@ def _grab(dest: str | Path, width) -> list[Path]: w.activateWindow() w.setMinimumHeight(40) w.grab().save(str(dest)) - - # hack to make sure the object is truly closed and deleted - while True: - QTimer.singleShot(10, w.deleteLater) - QApplication.processEvents() - try: - w.parent() - except RuntimeError: - return diff --git a/docs/utilities/thread_decorators.md b/docs/utilities/thread_decorators.md index 7ad4afd..9229a41 100644 --- a/docs/utilities/thread_decorators.md +++ b/docs/utilities/thread_decorators.md @@ -11,7 +11,7 @@ running in the desired thread: `ensure_object_thread` ensures that a decorated bound method of a `QObject` runs in the thread in which the instance lives ([see qt documentation for -details](https://doc.qt.io/qt-5/threads-qobject.html#accessing-qobject-subclasses-from-other-threads)). +details](https://doc.qt.io/qt-6/threads-qobject.html#accessing-qobject-subclasses-from-other-threads)). ## Usage diff --git a/docs/widgets/index.md b/docs/widgets/index.md index ef7250e..6bc2412 100644 --- a/docs/widgets/index.md +++ b/docs/widgets/index.md @@ -27,6 +27,7 @@ The following are QWidget subclasses: | [`QSearchableTreeWidget`](./qsearchabletreewidget.md) | `QTreeWidget` variant with search field that filters available options | | [`QColorComboBox`](./qcolorcombobox.md) | `QComboBox` to select from a specified set of colors | | [`QColormapComboBox`](./qcolormap.md) | `QComboBox` to select from a specified set of colormaps. | +| [`QToggleSwitch`](./qtoggleswitch.md) | `QAbstractButton` that represents a boolean value with a toggle switch. | ## Frames and containers diff --git a/docs/widgets/qenumcombobox.md b/docs/widgets/qenumcombobox.md index 466d952..0525fde 100644 --- a/docs/widgets/qenumcombobox.md +++ b/docs/widgets/qenumcombobox.md @@ -1,7 +1,7 @@ # QEnumComboBox `QEnumComboBox` is a variant of -[`QComboBox`](https://doc.qt.io/qt-5/qcombobox.html) that populates the items in +[`QComboBox`](https://doc.qt.io/qt-6/qcombobox.html) that populates the items in the combobox based on a python `Enum` class. In addition to all the methods provided by `QComboBox`, this subclass adds the methods `enumClass`/`setEnumClass` to get/set the current `Enum` class represented by diff --git a/docs/widgets/qrangeslider.md b/docs/widgets/qrangeslider.md index 237f87b..6d32427 100644 --- a/docs/widgets/qrangeslider.md +++ b/docs/widgets/qrangeslider.md @@ -20,7 +20,7 @@ app.exec_() {{ show_widget() }} -- `QRangeSlider` inherits from [`QSlider`](https://doc.qt.io/qt-5/qslider.html) +- `QRangeSlider` inherits from [`QSlider`](https://doc.qt.io/qt-6/qslider.html) and attempts to match the Qt API as closely as possible - It uses platform-specific styles (for handle, groove, & ticks) but also supports QSS style sheets. @@ -28,9 +28,9 @@ app.exec_() - Supports more than 2 handles (e.g. `slider.setValue([0, 10, 60, 80])`) As `QRangeSlider` inherits from -[`QtWidgets.QSlider`](https://doc.qt.io/qt-5/qslider.html), you can use all of +[`QtWidgets.QSlider`](https://doc.qt.io/qt-6/qslider.html), you can use all of the same methods available in the [QSlider -API](https://doc.qt.io/qt-5/qslider.html). The major difference is that `value()` +API](https://doc.qt.io/qt-6/qslider.html). The major difference is that `value()` and `sliderPosition()` are reimplemented as `tuples` of `int` (where the length of the tuple is equal to the number of handles in the slider.) diff --git a/docs/widgets/qsearchablecombobox.md b/docs/widgets/qsearchablecombobox.md index f5dea86..63fa325 100644 --- a/docs/widgets/qsearchablecombobox.md +++ b/docs/widgets/qsearchablecombobox.md @@ -1,7 +1,7 @@ # QSearchableComboBox `QSearchableComboBox` is a variant of -[`QComboBox`](https://doc.qt.io/qt-5/qcombobox.html) that allow to filter list +[`QComboBox`](https://doc.qt.io/qt-6/qcombobox.html) that allow to filter list of options by enter part of text. It could be drop in replacement for `QComboBox`. diff --git a/docs/widgets/qsearchablelistwidget.md b/docs/widgets/qsearchablelistwidget.md index ba90579..8277c0f 100644 --- a/docs/widgets/qsearchablelistwidget.md +++ b/docs/widgets/qsearchablelistwidget.md @@ -1,13 +1,13 @@ # QSearchableListWidget `QSearchableListWidget` is a variant of -[`QListWidget`](https://doc.qt.io/qt-5/qlistwidget.html) that add text entry +[`QListWidget`](https://doc.qt.io/qt-6/qlistwidget.html) that add text entry above list widget that allow to filter list of available options. Due to implementation details, this widget it does not inherit directly from -[`QListWidget`](https://doc.qt.io/qt-5/qlistwidget.html) but it does fully +[`QListWidget`](https://doc.qt.io/qt-6/qlistwidget.html) but it does fully satisfy its api. The only limitation is that it cannot be used as argument of -[`QListWidgetItem`](https://doc.qt.io/qt-5/qlistwidgetitem.html) constructor. +[`QListWidgetItem`](https://doc.qt.io/qt-6/qlistwidgetitem.html) constructor. ```python from qtpy.QtWidgets import QApplication diff --git a/docs/widgets/qtoggleswitch.md b/docs/widgets/qtoggleswitch.md new file mode 100644 index 0000000..7b1540e --- /dev/null +++ b/docs/widgets/qtoggleswitch.md @@ -0,0 +1,24 @@ +# QToggleSwitch + +`QToggleSwitch` is a +[`QAbstractButton`](https://doc.qt.io/qt-6/qabstractbutton.html) subclass +that represents a boolean value as a toggle switch. The API is similar to +[`QCheckBox`](https://doc.qt.io/qt-6/qcheckbox.html) but with a different +visual representation. + +```python +from qtpy.QtWidgets import QApplication + +from superqt import QToggleSwitch + +app = QApplication([]) + +switch = QToggleSwitch() +switch.show() + +app.exec_() +``` + +{{ show_widget(80) }} + +{{ show_members('superqt.QToggleSwitch') }} diff --git a/src/superqt/selection/_searchable_tree_widget.py b/src/superqt/selection/_searchable_tree_widget.py index 2276106..605f5f4 100644 --- a/src/superqt/selection/_searchable_tree_widget.py +++ b/src/superqt/selection/_searchable_tree_widget.py @@ -17,7 +17,7 @@ class QSearchableTreeWidget(QWidget): into the `filter` line edit. An item is only shown if its, any of its ancestors', or any of its descendants' keys or values match this pattern. The regular expression follows the conventions described by the Qt docs: - https://doc.qt.io/qt-5/qregularexpression.html#details + https://doc.qt.io/qt-6/qregularexpression.html#details Attributes ---------- diff --git a/src/superqt/utils/_qthreading.py b/src/superqt/utils/_qthreading.py index c433cb8..136b92e 100644 --- a/src/superqt/utils/_qthreading.py +++ b/src/superqt/utils/_qthreading.py @@ -766,7 +766,7 @@ def thread_worker( ############################################################################ # This is a variant on the above pattern, it uses QThread instead of Qrunnable -# see https://doc.qt.io/qt-5/threads-technologies.html#comparison-of-solutions +# see https://doc.qt.io/qt-6/threads-technologies.html#comparison-of-solutions # (it appears from that table that QRunnable cannot emit or receive signals, # but we circumvent that here with our WorkerBase class that also inherits from # QObject... providing signals/slots). @@ -777,7 +777,7 @@ def thread_worker( # # However, a disadvantage is that you have no access to (and therefore less # control over) the QThread itself. See for example all of the methods -# provided on the QThread object: https://doc.qt.io/qt-5/qthread.html +# provided on the QThread object: https://doc.qt.io/qt-6/qthread.html if TYPE_CHECKING: @@ -808,7 +808,7 @@ def new_worker_qthread( standard "single-threaded" signals & slots, note that inter-thread signals and slots (automatically) use an event-based QueuedConnection, while intra-thread signals use a DirectConnection. See [Signals and Slots Across - Threads](https://doc.qt.io/qt-5/threads-qobject.html#signals-and-slots-across-threads>) + Threads](https://doc.qt.io/qt-6/threads-qobject.html#signals-and-slots-across-threads>) Parameters ----------