aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/tests/QtUiTools
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside6/tests/QtUiTools')
-rw-r--r--sources/pyside6/tests/QtUiTools/CMakeLists.txt16
-rw-r--r--sources/pyside6/tests/QtUiTools/QtUiTools.pyproject28
-rw-r--r--sources/pyside6/tests/QtUiTools/action.ui16
-rw-r--r--sources/pyside6/tests/QtUiTools/bug_1060.py32
-rw-r--r--sources/pyside6/tests/QtUiTools/bug_1060.ui19
-rw-r--r--sources/pyside6/tests/QtUiTools/bug_360.py48
-rw-r--r--sources/pyside6/tests/QtUiTools/bug_376.py31
-rw-r--r--sources/pyside6/tests/QtUiTools/bug_392.py63
-rw-r--r--sources/pyside6/tests/QtUiTools/bug_426.py32
-rw-r--r--sources/pyside6/tests/QtUiTools/bug_426.ui19
-rw-r--r--sources/pyside6/tests/QtUiTools/bug_552.py37
-rw-r--r--sources/pyside6/tests/QtUiTools/bug_552.ui42
-rw-r--r--sources/pyside6/tests/QtUiTools/bug_797.py25
-rw-r--r--sources/pyside6/tests/QtUiTools/bug_909.py37
-rw-r--r--sources/pyside6/tests/QtUiTools/bug_909.ui31
-rw-r--r--sources/pyside6/tests/QtUiTools/bug_913.py32
-rw-r--r--sources/pyside6/tests/QtUiTools/bug_913.ui57
-rw-r--r--sources/pyside6/tests/QtUiTools/bug_958.py40
-rw-r--r--sources/pyside6/tests/QtUiTools/bug_958.ui48
-rw-r--r--sources/pyside6/tests/QtUiTools/bug_965.py35
-rw-r--r--sources/pyside6/tests/QtUiTools/bug_965.ui27
-rw-r--r--sources/pyside6/tests/QtUiTools/loadUiType_test.py52
-rw-r--r--sources/pyside6/tests/QtUiTools/minimal.ui6
-rw-r--r--sources/pyside6/tests/QtUiTools/pycustomwidget.ui36
-rw-r--r--sources/pyside6/tests/QtUiTools/pycustomwidget2.ui48
-rw-r--r--sources/pyside6/tests/QtUiTools/test.ui48
-rw-r--r--sources/pyside6/tests/QtUiTools/ui_test.py25
-rw-r--r--sources/pyside6/tests/QtUiTools/uiloader_test.py54
28 files changed, 984 insertions, 0 deletions
diff --git a/sources/pyside6/tests/QtUiTools/CMakeLists.txt b/sources/pyside6/tests/QtUiTools/CMakeLists.txt
new file mode 100644
index 000000000..08c6f1577
--- /dev/null
+++ b/sources/pyside6/tests/QtUiTools/CMakeLists.txt
@@ -0,0 +1,16 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+PYSIDE_TEST(bug_360.py)
+PYSIDE_TEST(bug_376.py)
+PYSIDE_TEST(bug_392.py)
+PYSIDE_TEST(bug_426.py)
+PYSIDE_TEST(bug_552.py)
+PYSIDE_TEST(bug_797.py)
+PYSIDE_TEST(bug_909.py)
+PYSIDE_TEST(bug_913.py)
+PYSIDE_TEST(bug_958.py)
+PYSIDE_TEST(bug_965.py)
+PYSIDE_TEST(bug_1060.py)
+PYSIDE_TEST(uiloader_test.py)
+PYSIDE_TEST(ui_test.py)
diff --git a/sources/pyside6/tests/QtUiTools/QtUiTools.pyproject b/sources/pyside6/tests/QtUiTools/QtUiTools.pyproject
new file mode 100644
index 000000000..a83758b87
--- /dev/null
+++ b/sources/pyside6/tests/QtUiTools/QtUiTools.pyproject
@@ -0,0 +1,28 @@
+{
+ "files": ["action.ui",
+ "bug_1060.py",
+ "bug_1060.ui",
+ "bug_360.py",
+ "bug_376.py",
+ "bug_392.py",
+ "bug_426.py",
+ "bug_426.ui",
+ "bug_552.py",
+ "bug_552.ui",
+ "bug_797.py",
+ "bug_909.py",
+ "bug_909.ui",
+ "bug_913.py",
+ "bug_913.ui",
+ "bug_958.py",
+ "bug_958.ui",
+ "bug_965.py",
+ "bug_965.ui",
+ "loadUiType_test.py",
+ "minimal.ui",
+ "pycustomwidget.ui",
+ "pycustomwidget2.ui",
+ "test.ui",
+ "ui_test.py",
+ "uiloader_test.py"]
+}
diff --git a/sources/pyside6/tests/QtUiTools/action.ui b/sources/pyside6/tests/QtUiTools/action.ui
new file mode 100644
index 000000000..9eda559de
--- /dev/null
+++ b/sources/pyside6/tests/QtUiTools/action.ui
@@ -0,0 +1,16 @@
+<ui version="4.0">
+ <class>main_window</class>
+ <widget class="QMainWindow" name="main_window">
+ <widget class="QWidget" name="centralwidget"/>
+ <widget class="QMenuBar" name="menubar"/>
+ <widget class="QStatusBar" name="statusbar">
+ <action name="actionFoo">
+ <property name="text">
+ <string>foo</string>
+ </property>
+ </action>
+ </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/sources/pyside6/tests/QtUiTools/bug_1060.py b/sources/pyside6/tests/QtUiTools/bug_1060.py
new file mode 100644
index 000000000..52624a2a9
--- /dev/null
+++ b/sources/pyside6/tests/QtUiTools/bug_1060.py
@@ -0,0 +1,32 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+''' unit test for BUG #1060 '''
+
+import os
+import sys
+
+from pathlib import Path
+sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
+from init_paths import init_test_paths
+init_test_paths(False)
+
+from PySide6.QtWidgets import QApplication
+from PySide6.QtUiTools import QUiLoader
+
+
+class MyQUiLoader(QUiLoader):
+ def __init__(self):
+ super().__init__()
+
+ def createWidget(self, *args):
+ return super(MyQUiLoader, self).createWidget(*args)
+
+
+if __name__ == "__main__":
+ app = QApplication([])
+
+ file = Path(__file__).resolve().parent / 'bug_1060.ui'
+ assert (file.is_file())
+ ui = MyQUiLoader().load(file)
+ ui.show()
diff --git a/sources/pyside6/tests/QtUiTools/bug_1060.ui b/sources/pyside6/tests/QtUiTools/bug_1060.ui
new file mode 100644
index 000000000..f4044a8c2
--- /dev/null
+++ b/sources/pyside6/tests/QtUiTools/bug_1060.ui
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Dialog</class>
+ <widget class="QDialog" name="Dialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>100</width>
+ <height>100</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/sources/pyside6/tests/QtUiTools/bug_360.py b/sources/pyside6/tests/QtUiTools/bug_360.py
new file mode 100644
index 000000000..8ca764eae
--- /dev/null
+++ b/sources/pyside6/tests/QtUiTools/bug_360.py
@@ -0,0 +1,48 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import os
+import sys
+import unittest
+
+from pathlib import Path
+sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
+from init_paths import init_test_paths
+init_test_paths(False)
+
+from helper.usesqapplication import UsesQApplication
+from PySide6.QtWidgets import QFrame, QWidget
+from PySide6.QtUiTools import QUiLoader
+
+
+class MyQUiLoader(QUiLoader):
+ def __init__(self, baseinstance):
+ super().__init__()
+ self.baseinstance = baseinstance
+ self._widgets = []
+
+ def createWidget(self, className, parent=None, name=""):
+ widget = QUiLoader.createWidget(self, className, parent, name)
+ self._widgets.append(widget)
+ if parent is None:
+ return self.baseinstance
+ else:
+ setattr(self.baseinstance, name, widget)
+ return widget
+
+
+class ButTest(UsesQApplication):
+ def testCase(self):
+ w = QWidget()
+ loader = MyQUiLoader(w)
+
+ filePath = os.path.join(os.path.dirname(__file__), 'minimal.ui')
+ ui = loader.load(filePath)
+
+ self.assertEqual(len(loader._widgets), 1)
+ self.assertEqual(type(loader._widgets[0]), QFrame)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside6/tests/QtUiTools/bug_376.py b/sources/pyside6/tests/QtUiTools/bug_376.py
new file mode 100644
index 000000000..eefc1fe05
--- /dev/null
+++ b/sources/pyside6/tests/QtUiTools/bug_376.py
@@ -0,0 +1,31 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import os
+import sys
+import unittest
+
+from pathlib import Path
+sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
+from init_paths import init_test_paths
+init_test_paths(False)
+
+from helper.usesqapplication import UsesQApplication
+
+from PySide6.QtWidgets import QFrame, QWidget
+from PySide6.QtUiTools import QUiLoader
+
+
+class BugTest(UsesQApplication):
+ def testCase(self):
+ w = QWidget()
+ loader = QUiLoader()
+
+ filePath = os.path.join(os.path.dirname(__file__), 'test.ui')
+ result = loader.load(filePath, w)
+ self.assertTrue(isinstance(result.child_object, QFrame))
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside6/tests/QtUiTools/bug_392.py b/sources/pyside6/tests/QtUiTools/bug_392.py
new file mode 100644
index 000000000..4d69fdbec
--- /dev/null
+++ b/sources/pyside6/tests/QtUiTools/bug_392.py
@@ -0,0 +1,63 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import os
+import sys
+import unittest
+
+from pathlib import Path
+sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
+from init_paths import init_test_paths
+init_test_paths(False)
+
+from helper.usesqapplication import UsesQApplication
+
+from PySide6.QtGui import QAction
+from PySide6.QtWidgets import QComboBox, QWidget
+from PySide6.QtUiTools import QUiLoader
+
+
+class MyWidget(QComboBox):
+ def __init__(self, parent=None):
+ QComboBox.__init__(self, parent)
+
+ def isPython(self):
+ return True
+
+
+class BugTest(UsesQApplication):
+ def testCase(self):
+ w = QWidget()
+ loader = QUiLoader()
+
+ filePath = os.path.join(os.path.dirname(__file__), 'action.ui')
+ result = loader.load(filePath, w)
+ self.assertTrue(isinstance(result.actionFoo, QAction))
+
+ def testPythonCustomWidgets(self):
+ w = QWidget()
+ loader = QUiLoader()
+ loader.registerCustomWidget(MyWidget)
+ self.assertTrue('MyWidget' in loader.availableWidgets())
+
+ filePath = os.path.join(os.path.dirname(__file__), 'pycustomwidget.ui')
+ result = loader.load(filePath, w)
+ self.assertTrue(isinstance(result.custom, MyWidget))
+ self.assertTrue(result.custom.isPython())
+
+ def testPythonCustomWidgetsTwice(self):
+ w = QWidget()
+ loader = QUiLoader()
+ loader.registerCustomWidget(MyWidget)
+ self.assertTrue('MyWidget' in loader.availableWidgets())
+
+ filePath = os.path.join(os.path.dirname(__file__), 'pycustomwidget2.ui')
+ result = loader.load(filePath, w)
+ self.assertTrue(isinstance(result.custom, MyWidget))
+ self.assertTrue(isinstance(result.custom2, MyWidget))
+ self.assertTrue(result.custom.isPython())
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside6/tests/QtUiTools/bug_426.py b/sources/pyside6/tests/QtUiTools/bug_426.py
new file mode 100644
index 000000000..3a568e4e2
--- /dev/null
+++ b/sources/pyside6/tests/QtUiTools/bug_426.py
@@ -0,0 +1,32 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import os
+import sys
+import unittest
+
+from pathlib import Path
+sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
+from init_paths import init_test_paths
+init_test_paths(False)
+
+from PySide6.QtCore import QTimer
+from PySide6.QtGui import QAction, QActionGroup
+from PySide6.QtWidgets import QApplication, QWidget
+from PySide6.QtUiTools import QUiLoader
+
+
+class Window(object):
+ def __init__(self):
+ loader = QUiLoader()
+ filePath = os.path.join(os.path.dirname(__file__), 'bug_426.ui')
+ self.widget = loader.load(filePath)
+ self.group = QActionGroup(self.widget)
+ self.widget.show()
+ QTimer.singleShot(0, self.widget.close)
+
+
+if __name__ == "__main__":
+ app = QApplication(sys.argv)
+ win = Window()
+ sys.exit(app.exec())
diff --git a/sources/pyside6/tests/QtUiTools/bug_426.ui b/sources/pyside6/tests/QtUiTools/bug_426.ui
new file mode 100644
index 000000000..99353cd2b
--- /dev/null
+++ b/sources/pyside6/tests/QtUiTools/bug_426.ui
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/sources/pyside6/tests/QtUiTools/bug_552.py b/sources/pyside6/tests/QtUiTools/bug_552.py
new file mode 100644
index 000000000..06a6b72a4
--- /dev/null
+++ b/sources/pyside6/tests/QtUiTools/bug_552.py
@@ -0,0 +1,37 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import os
+import sys
+import unittest
+
+from pathlib import Path
+sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
+from init_paths import init_test_paths
+init_test_paths(False)
+
+from PySide6.QtCore import QObject
+from PySide6.QtWidgets import QApplication, QFrame, QWidget
+from PySide6.QtUiTools import QUiLoader
+
+
+class View_1(QWidget):
+
+ def __init__(self):
+ super().__init__()
+ loader = QUiLoader()
+ file = Path(__file__).resolve().parent / 'bug_552.ui'
+ assert (file.is_file())
+ widget = loader.load(os.fspath(file), self)
+ self.children = []
+ for child in widget.findChildren(QObject, None):
+ self.children.append(child)
+ self.t = widget.tabWidget
+ self.t.removeTab(0)
+
+
+app = QApplication([])
+window = View_1()
+window.show()
+
+# If it doesn't crash it works :-)
diff --git a/sources/pyside6/tests/QtUiTools/bug_552.ui b/sources/pyside6/tests/QtUiTools/bug_552.ui
new file mode 100644
index 000000000..f98da4421
--- /dev/null
+++ b/sources/pyside6/tests/QtUiTools/bug_552.ui
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <widget class="QTabWidget" name="tabWidget">
+ <property name="geometry">
+ <rect>
+ <x>130</x>
+ <y>80</y>
+ <width>139</width>
+ <height>80</height>
+ </rect>
+ </property>
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="tab">
+ <attribute name="title">
+ <string>Tab 1</string>
+ </attribute>
+ </widget>
+ <widget class="QWidget" name="tab_2">
+ <attribute name="title">
+ <string>Tab 2</string>
+ </attribute>
+ </widget>
+ </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/sources/pyside6/tests/QtUiTools/bug_797.py b/sources/pyside6/tests/QtUiTools/bug_797.py
new file mode 100644
index 000000000..3dae7afb7
--- /dev/null
+++ b/sources/pyside6/tests/QtUiTools/bug_797.py
@@ -0,0 +1,25 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import os
+import sys
+import unittest
+
+from pathlib import Path
+sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
+from init_paths import init_test_paths
+init_test_paths(False)
+
+from PySide6.QtUiTools import QUiLoader
+from PySide6.QtCore import QFile
+from PySide6.QtWidgets import QApplication, QWidget
+
+
+app = QApplication([])
+loader = QUiLoader()
+file = Path(__file__).resolve().parent / 'bug_552.ui'
+assert (file.is_file())
+file = QFile(file)
+w = QWidget()
+# An exception can't be thrown
+mainWindow = loader.load(file, w)
diff --git a/sources/pyside6/tests/QtUiTools/bug_909.py b/sources/pyside6/tests/QtUiTools/bug_909.py
new file mode 100644
index 000000000..cd4d50a0b
--- /dev/null
+++ b/sources/pyside6/tests/QtUiTools/bug_909.py
@@ -0,0 +1,37 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import os
+import sys
+import unittest
+
+from pathlib import Path
+sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
+from init_paths import init_test_paths
+init_test_paths(False)
+
+from PySide6.QtCore import QFile
+from PySide6.QtWidgets import QTabWidget
+from PySide6.QtUiTools import QUiLoader
+
+from helper.usesqapplication import UsesQApplication
+
+
+class TestDestruction(UsesQApplication):
+ @unittest.skipUnless(hasattr(sys, "getrefcount"), f"{sys.implementation.name} has no refcount")
+ def testBug909(self):
+ file = Path(__file__).resolve().parent / 'bug_909.ui'
+ self.assertTrue(file.is_file())
+ fileName = QFile(file)
+ loader = QUiLoader()
+ main_win = loader.load(fileName)
+ self.assertEqual(sys.getrefcount(main_win), 2)
+ fileName.close()
+
+ tw = QTabWidget(main_win)
+ main_win.setCentralWidget(tw)
+ main_win.show()
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside6/tests/QtUiTools/bug_909.ui b/sources/pyside6/tests/QtUiTools/bug_909.ui
new file mode 100644
index 000000000..b07f62d05
--- /dev/null
+++ b/sources/pyside6/tests/QtUiTools/bug_909.ui
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>600</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="centralwidget"/>
+ <widget class="QMenuBar" name="menubar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>25</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QStatusBar" name="statusbar"/>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/sources/pyside6/tests/QtUiTools/bug_913.py b/sources/pyside6/tests/QtUiTools/bug_913.py
new file mode 100644
index 000000000..85df29d11
--- /dev/null
+++ b/sources/pyside6/tests/QtUiTools/bug_913.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import os
+import sys
+import unittest
+
+from pathlib import Path
+sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
+from init_paths import init_test_paths
+init_test_paths(False)
+
+from PySide6.QtWidgets import QApplication
+from PySide6.QtUiTools import QUiLoader
+
+
+class TestBug913 (unittest.TestCase):
+
+ def testIt(self):
+ app = QApplication([])
+
+ loader = QUiLoader()
+ file = Path(__file__).resolve().parent / 'bug_913.ui'
+ self.assertTrue(file.is_file())
+ widget = loader.load(file)
+ widget.tabWidget.currentIndex() # direct child is available as member
+ widget.le_first.setText('foo') # child of QTabWidget must also be available!
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside6/tests/QtUiTools/bug_913.ui b/sources/pyside6/tests/QtUiTools/bug_913.ui
new file mode 100644
index 000000000..0fc95fd53
--- /dev/null
+++ b/sources/pyside6/tests/QtUiTools/bug_913.ui
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QTabWidget" name="tabWidget">
+ <widget class="QWidget" name="tab">
+ <attribute name="title">
+ <string>Tab 1</string>
+ </attribute>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>First name:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="le_first"/>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Last name:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="le_last"/>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab_2">
+ <attribute name="title">
+ <string>Tab 2</string>
+ </attribute>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/sources/pyside6/tests/QtUiTools/bug_958.py b/sources/pyside6/tests/QtUiTools/bug_958.py
new file mode 100644
index 000000000..2f8dfab62
--- /dev/null
+++ b/sources/pyside6/tests/QtUiTools/bug_958.py
@@ -0,0 +1,40 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import os
+import sys
+import unittest
+
+from pathlib import Path
+sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
+from init_paths import init_test_paths
+init_test_paths(False)
+
+from PySide6.QtWidgets import QMainWindow
+from PySide6.QtUiTools import QUiLoader
+from helper.timedqapplication import TimedQApplication
+
+
+class Gui_Qt(QMainWindow):
+ def __init__(self, parent=None):
+ super().__init__(parent)
+
+ lLoader = QUiLoader()
+
+ # this used to cause a segfault because the old inject code used to destroy the parent layout
+ file = Path(__file__).resolve().parent / 'bug_958.ui'
+ assert (file.is_file())
+ self._cw = lLoader.load(file, self)
+
+ self.setCentralWidget(self._cw)
+
+
+class BugTest(TimedQApplication):
+ def testCase(self):
+ lMain = Gui_Qt()
+ lMain.show()
+ self.app.exec()
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/sources/pyside6/tests/QtUiTools/bug_958.ui b/sources/pyside6/tests/QtUiTools/bug_958.ui
new file mode 100644
index 000000000..57cdbddba
--- /dev/null
+++ b/sources/pyside6/tests/QtUiTools/bug_958.ui
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>customWidget</class>
+ <widget class="QWidget" name="customWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>626</width>
+ <height>578</height>
+ </rect>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>500</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QTableWidget" name="resultTable"/>
+ </item>
+ <item>
+ <widget class="QProgressBar" name="progressBar">
+ <property name="value">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="actionLayout">
+ <item>
+ <widget class="QPushButton" name="processButton">
+ <property name="text">
+ <string>&amp;Berechnen</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/sources/pyside6/tests/QtUiTools/bug_965.py b/sources/pyside6/tests/QtUiTools/bug_965.py
new file mode 100644
index 000000000..2308cbeed
--- /dev/null
+++ b/sources/pyside6/tests/QtUiTools/bug_965.py
@@ -0,0 +1,35 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import os
+import sys
+import unittest
+
+from pathlib import Path
+sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
+from init_paths import init_test_paths
+init_test_paths(False)
+
+from PySide6.QtUiTools import QUiLoader
+
+from helper.usesqapplication import UsesQApplication
+
+
+class MyQUiLoader(QUiLoader):
+ def __init__(self):
+ super().__init__()
+
+ def createWidget(self, className, parent=None, name=""):
+ return None
+
+
+class BugTest(UsesQApplication):
+ def testCase(self):
+ loader = MyQUiLoader()
+ file = Path(__file__).resolve().parent / 'bug_965.ui'
+ self.assertTrue(file.is_file())
+ self.assertRaises(RuntimeError, loader.load, file)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside6/tests/QtUiTools/bug_965.ui b/sources/pyside6/tests/QtUiTools/bug_965.ui
new file mode 100644
index 000000000..e324db829
--- /dev/null
+++ b/sources/pyside6/tests/QtUiTools/bug_965.ui
@@ -0,0 +1,27 @@
+<ui version="4.0" >
+ <author></author>
+ <comment></comment>
+ <exportmacro></exportmacro>
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow" >
+ <property name="objectName" >
+ <string notr="true" >MainWindow</string>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>600</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>MainWindow</string>
+ </property>
+ <widget class="QMenuBar" name="menubar" />
+ <widget class="QWidget" name="centralwidget" />
+ <widget class="QStatusBar" name="statusbar" />
+ </widget>
+ <pixmapfunction></pixmapfunction>
+ <connections/>
+</ui>
diff --git a/sources/pyside6/tests/QtUiTools/loadUiType_test.py b/sources/pyside6/tests/QtUiTools/loadUiType_test.py
new file mode 100644
index 000000000..b0842318c
--- /dev/null
+++ b/sources/pyside6/tests/QtUiTools/loadUiType_test.py
@@ -0,0 +1,52 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import os
+import sys
+import unittest
+
+from pathlib import Path
+sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
+from init_paths import init_test_paths
+init_test_paths(False)
+
+from helper.usesqapplication import UsesQApplication
+
+from PySide6.QtWidgets import QWidget, QFrame, QPushButton
+from PySide6.QtUiTools import loadUiType
+
+
+class loadUiTypeTester(UsesQApplication):
+ def testFunction(self):
+ filePath = os.path.join(os.path.dirname(__file__), "minimal.ui")
+ loaded = loadUiType(filePath)
+ self.assertNotEqual(loaded, None)
+
+ # (<class '__main__.Ui_Form'>, <class 'PySide6.QtWidgets.QFrame'>)
+ generated, base = loaded
+
+ # Generated class contains retranslateUi method
+ self.assertTrue("retranslateUi" in dir(generated))
+
+ # Base class instance will be QFrame for this example
+ self.assertTrue(isinstance(base(), QFrame))
+
+ anotherFileName = os.path.join(os.path.dirname(__file__), "test.ui")
+ another = loadUiType(anotherFileName)
+ self.assertNotEqual(another, None)
+
+ generated, base = another
+ # Base class instance will be QWidget for this example
+ self.assertTrue(isinstance(base(), QWidget))
+
+ w = base()
+ ui = generated()
+ ui.setupUi(w)
+
+ self.assertTrue(isinstance(ui.child_object, QFrame))
+ self.assertTrue(isinstance(ui.grandson_object, QPushButton))
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside6/tests/QtUiTools/minimal.ui b/sources/pyside6/tests/QtUiTools/minimal.ui
new file mode 100644
index 000000000..c6bb70cda
--- /dev/null
+++ b/sources/pyside6/tests/QtUiTools/minimal.ui
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QFrame" name="Form">
+ </widget>
+</ui>
diff --git a/sources/pyside6/tests/QtUiTools/pycustomwidget.ui b/sources/pyside6/tests/QtUiTools/pycustomwidget.ui
new file mode 100644
index 000000000..c066153a0
--- /dev/null
+++ b/sources/pyside6/tests/QtUiTools/pycustomwidget.ui
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>qwidget</class>
+ <widget class="QWidget" name="qwidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string/>
+ </property>
+ <widget class="MyWidget" name="custom">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>79</width>
+ <height>23</height>
+ </rect>
+ </property>
+ </widget>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>MyWidget</class>
+ <extends>QComboBox</extends>
+ <header>customwidget</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/sources/pyside6/tests/QtUiTools/pycustomwidget2.ui b/sources/pyside6/tests/QtUiTools/pycustomwidget2.ui
new file mode 100644
index 000000000..8826ac1fb
--- /dev/null
+++ b/sources/pyside6/tests/QtUiTools/pycustomwidget2.ui
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>qwidget</class>
+ <widget class="QWidget" name="qwidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string/>
+ </property>
+
+ <widget class="MyWidget" name="custom">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>79</width>
+ <height>23</height>
+ </rect>
+ </property>
+ </widget>
+
+ <widget class="MyWidget" name="custom2">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>79</width>
+ <height>23</height>
+ </rect>
+ </property>
+ </widget>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>MyWidget</class>
+ <extends>QComboBox</extends>
+ <header>customwidget</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/sources/pyside6/tests/QtUiTools/test.ui b/sources/pyside6/tests/QtUiTools/test.ui
new file mode 100644
index 000000000..60afe22b3
--- /dev/null
+++ b/sources/pyside6/tests/QtUiTools/test.ui
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>185</width>
+ <height>133</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <widget class="QFrame" name="child_object">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>181</width>
+ <height>131</height>
+ </rect>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <widget class="QPushButton" name="grandson_object">
+ <property name="geometry">
+ <rect>
+ <x>50</x>
+ <y>60</y>
+ <width>80</width>
+ <height>25</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>PushButton</string>
+ </property>
+ </widget>
+ </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/sources/pyside6/tests/QtUiTools/ui_test.py b/sources/pyside6/tests/QtUiTools/ui_test.py
new file mode 100644
index 000000000..4e2fa808b
--- /dev/null
+++ b/sources/pyside6/tests/QtUiTools/ui_test.py
@@ -0,0 +1,25 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import os
+import sys
+import unittest
+
+from pathlib import Path
+sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
+from init_paths import init_test_paths
+init_test_paths(False)
+
+from PySide6.QtUiTools import QUiLoader
+
+from helper.usesqapplication import UsesQApplication
+
+
+class QUiLoaderCreation(UsesQApplication):
+
+ def testConstructor(self):
+ loader = QUiLoader()
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside6/tests/QtUiTools/uiloader_test.py b/sources/pyside6/tests/QtUiTools/uiloader_test.py
new file mode 100644
index 000000000..19e26912e
--- /dev/null
+++ b/sources/pyside6/tests/QtUiTools/uiloader_test.py
@@ -0,0 +1,54 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+import os
+import sys
+import unittest
+
+from pathlib import Path
+sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
+from init_paths import init_test_paths
+init_test_paths(False)
+
+from helper.usesqapplication import UsesQApplication
+
+from PySide6.QtWidgets import QWidget
+from PySide6.QtUiTools import QUiLoader
+
+
+class OverridingLoader(QUiLoader):
+ def createWidget(self, class_name, parent=None, name=''):
+ if class_name == 'QWidget':
+ w = QWidget(parent)
+ w.setObjectName(name)
+ return w
+ return QUiLoader.createWidget(self, class_name, parent, name)
+
+
+class QUiLoaderTester(UsesQApplication):
+ def setUp(self):
+ UsesQApplication.setUp(self)
+ self._filePath = os.path.join(os.path.dirname(__file__), 'test.ui')
+
+ def testLoadFile(self):
+ loader = QUiLoader()
+ parent = QWidget()
+ w = loader.load(self._filePath, parent)
+ self.assertNotEqual(w, None)
+
+ self.assertEqual(len(parent.children()), 1)
+
+ child = w.findChild(QWidget, "child_object")
+ self.assertNotEqual(child, None)
+ self.assertEqual(w.findChild(QWidget, "grandson_object"), child.findChild(QWidget, "grandson_object"))
+
+ def testLoadFileOverride(self):
+ # PYSIDE-1070, override QUiLoader::createWidget() with parent=None crashes
+ loader = OverridingLoader()
+ w = loader.load(self._filePath)
+ self.assertNotEqual(w, None)
+
+
+if __name__ == '__main__':
+ unittest.main()
+