aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/doc/extras/QtUiTools.loadUiType.rst
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-11-02 16:11:52 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-11-02 16:12:04 +0000
commit25180730194bec25f915f32ab846ea583fb1493f (patch)
tree9a73e0336ecf21e085d99d6a651c5547b9eb99f8 /sources/pyside6/doc/extras/QtUiTools.loadUiType.rst
parent6e3e7b9ca0548430aaa5e2555d6e02c64625fa3f (diff)
Rename PySide2 to PySide6
Adapt CMake files, build scripts, tests and examples. Task-number: PYSIDE-904 Change-Id: I845f7b006e9ad274fed5444ec4c1f9dbe176ff88 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside6/doc/extras/QtUiTools.loadUiType.rst')
-rw-r--r--sources/pyside6/doc/extras/QtUiTools.loadUiType.rst36
1 files changed, 36 insertions, 0 deletions
diff --git a/sources/pyside6/doc/extras/QtUiTools.loadUiType.rst b/sources/pyside6/doc/extras/QtUiTools.loadUiType.rst
new file mode 100644
index 000000000..8a8c4bef0
--- /dev/null
+++ b/sources/pyside6/doc/extras/QtUiTools.loadUiType.rst
@@ -0,0 +1,36 @@
+.. currentmodule:: PySide6.QtUiTools
+.. _loadUiType:
+
+loadUiType
+***********
+
+.. py:function:: loadUiType(uifile: str) -> tuple(object, object)
+
+ :param str uifile: The name of the `.ui` file
+ :return: tuple(object, object)
+
+ This function generates and loads a `.ui` file at runtime, and it returns
+ a `tuple` containing the reference to the Python class, and the base class.
+
+ We recommend not to use this approach as the workflow should be to generate a Python file
+ from the `.ui` file, and then import and load it to use it, but we do understand that
+ there are some corner cases when such functionality is required.
+
+ The internal process relies on `uic` being in the PATH.
+ The `pyside6-uic` wrapper uses a shipped `uic` that is located in the
+ `site-packages/PySide6/uic`, so PATH needs to be updated to use that if there
+ is no `uic` in the system.
+
+ A simple use case is::
+
+ from PySide6.QtUiTools import loadUiType
+
+ generated_class, base_class = loadUiType("themewidget.ui")
+ # the values will be:
+ # (<class '__main__.Ui_ThemeWidgetForm'>, <class 'PySide6.QtWidgets.QWidget'>)
+
+ widget = base_class()
+ form = generated_class()
+ form.setupUi(widget)
+ # form.a_widget_member.a_method_of_member()
+ widget.show()