summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLauro Neto <lauro.neto@openbossa.org>2010-10-06 19:18:19 -0300
committerLauro Neto <lauro.neto@openbossa.org>2010-10-07 15:10:11 -0300
commit04180e1f1d9e5dc2b8e8e856f6fde0587074284a (patch)
tree7fe9c7b0d3ec6d7c4e277ae892bee71b0ad1d187
parent3c7f55855b45168818ef6fc5e58b30f1c7e4d133 (diff)
downloadpyside-04180e1f1d9e5dc2b8e8e856f6fde0587074284a.tar.gz
pyside-04180e1f1d9e5dc2b8e8e856f6fde0587074284a.tar.xz
pyside-04180e1f1d9e5dc2b8e8e856f6fde0587074284a.zip
Add default name for QObject.findChild(type, name)
Plus test. Should return a child of the given type.
-rw-r--r--PySide/QtCore/typesystem_core.xml3
-rw-r--r--tests/QtCore/qobject_parent_test.py11
2 files changed, 14 insertions, 0 deletions
diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml
index 37decba..db7777e 100644
--- a/PySide/QtCore/typesystem_core.xml
+++ b/PySide/QtCore/typesystem_core.xml
@@ -1165,6 +1165,9 @@
<modify-argument index="return">
<parent index="this" action="add"/>
</modify-argument>
+ <modify-argument index="2">
+ <replace-default-expression with="QString()" />
+ </modify-argument>
</add-function>
<add-function signature="findChildren(PyTypeObject*, const QString&amp;)" return-type="PySequence*" >
<inject-code class="target" position="beginning">
diff --git a/tests/QtCore/qobject_parent_test.py b/tests/QtCore/qobject_parent_test.py
index 4699fc6..eb8cae2 100644
--- a/tests/QtCore/qobject_parent_test.py
+++ b/tests/QtCore/qobject_parent_test.py
@@ -71,6 +71,17 @@ class ParentCase(unittest.TestCase):
for i, child in enumerate(children):
self.assertEqual(child, parent.findChild(QObject, name % i))
+ def testFindChildWithoutName(self):
+ parent = QObject()
+ name = 'object%d'
+ children = [QObject(parent) for i in range(20)]
+
+ for i, child in enumerate(children):
+ child.setObjectName(name % i)
+
+ child = parent.findChild(QObject)
+ self.assert_(isinstance(child, QObject))
+
def testFindChildren(self):
#QObject.findChildren() with all QObject
parent = QObject()