aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2024-03-01 10:51:27 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2024-03-01 13:02:50 +0100
commit019a1932c559f0d73d2d8bcd4b3b26ba03dbccb8 (patch)
tree94a1bae717774cee430f9a5d7e6cc53a4cf44e97
parent3a28afe3229e331c410045729508477cb9f2d53e (diff)
Documentation: List loadUiType() as a function instead a class
Move the loadUiType() documentation into a doc snippet. Task-number: PYSIDE-1106 Change-Id: I3f878e054f2e6c3a0570f06a340d87661f27cd11 Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io>
-rw-r--r--sources/pyside6/PySide6/QtUiTools/typesystem_uitools.xml8
-rw-r--r--sources/pyside6/PySide6/doc/qtuitools.rst39
-rw-r--r--sources/pyside6/doc/extras/QtUiTools.loadUiType.rst35
3 files changed, 45 insertions, 37 deletions
diff --git a/sources/pyside6/PySide6/QtUiTools/typesystem_uitools.xml b/sources/pyside6/PySide6/QtUiTools/typesystem_uitools.xml
index 551cd4235..4cd5391a9 100644
--- a/sources/pyside6/PySide6/QtUiTools/typesystem_uitools.xml
+++ b/sources/pyside6/PySide6/QtUiTools/typesystem_uitools.xml
@@ -14,8 +14,10 @@
<inject-code class="native" position="beginning" file="../glue/qtuitools.cpp" snippet="uitools-loadui"/>
<inject-code file="../glue/qtuitools.cpp" snippet="quiloader"/>
<add-function signature="registerCustomWidget(PyObject*@customWidgetType@)" return-type="void">
- <inject-documentation format="target" mode="append" file="../doc/qtuitools.rst"/>
- <inject-code class="target" position="beginning" file="../glue/qtuitools.cpp" snippet="quiloader-registercustomwidget"/>
+ <inject-documentation format="target" mode="append" file="../doc/qtuitools.rst"
+ snippet="quiloader-registercustomwidget"/>
+ <inject-code class="target" position="beginning" file="../glue/qtuitools.cpp"
+ snippet="quiloader-registercustomwidget"/>
</add-function>
<modify-function signature="createAction(QObject*,const QString&amp;)">
<modify-argument index="return">
@@ -77,6 +79,8 @@
-->
<add-function signature="loadUiType(const QString&amp; @uifile@)" return-type="PyObject*">
<inject-code file="../glue/qtuitools.cpp" snippet="loaduitype"/>
+ <inject-documentation format="target" mode="append" file="../doc/qtuitools.rst"
+ snippet="loaduitype"/>
</add-function>
diff --git a/sources/pyside6/PySide6/doc/qtuitools.rst b/sources/pyside6/PySide6/doc/qtuitools.rst
index 5f534793a..a8856f1af 100644
--- a/sources/pyside6/PySide6/doc/qtuitools.rst
+++ b/sources/pyside6/PySide6/doc/qtuitools.rst
@@ -1,3 +1,4 @@
+// @snippet quiloader-registercustomwidget
Registers a Python created custom widget to QUiLoader, so it can be recognized
when loading a `.ui` file. The custom widget type is passed via the
``customWidgetType`` argument. This is needed when you want to override a
@@ -27,3 +28,41 @@ overriding :class:`~PySide6.QtGui.QWidget`'s :meth:`~PySide6.QtGui.QWidget.paint
circle.show()
# ...
+// @snippet quiloader-registercustomwidget
+
+// @snippet loaduitype
+.. currentmodule:: PySide6.QtUiTools
+
+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()
+// @snippet loaduitype
diff --git a/sources/pyside6/doc/extras/QtUiTools.loadUiType.rst b/sources/pyside6/doc/extras/QtUiTools.loadUiType.rst
deleted file mode 100644
index 48879d263..000000000
--- a/sources/pyside6/doc/extras/QtUiTools.loadUiType.rst
+++ /dev/null
@@ -1,35 +0,0 @@
-.. currentmodule:: PySide6.QtUiTools
-
-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()