Add default name for QObject.findChild(type, name)

Plus test.
Should return a child of the given type.
This commit is contained in:
Lauro Neto 2010-10-06 19:18:19 -03:00
commit 04180e1f1d
2 changed files with 14 additions and 0 deletions

View file

@ -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()