[PyKDE] QObject.findChildren doesn't work as expected with QRegExp

Andreas Pakulat apaku at gmx.de
Fri Mar 2 12:15:33 GMT 2007

On 01.03.07 19:53:45, Kerri Reno wrote:
> I have the following code:
> 	def testfindChildren(self):
> 		hLayout = QtGui.QHBoxLayout()
> 		hLayout.setObjectName('hLayout_0')
> 		self.searchLayout.addLayout(hLayout)
> 		print self.findChild(QtGui.QHBoxLayout,'hLayout_0')
> 		children = self.findChildren(QtGui.QHBoxLayout,QtCore.QRegExp('\w*'))
> 		for c in children:
> 			print c.objectName()
> 		print self.findChildren(QtGui.QHBoxLayout,QtCore.QRegExp('hLayout_\d'))
> The one I need, findChildren with a QRegex does not return hLayout_0 in
> the list.  Am I doing something wrong here?  Is this a bug?  I can't see
> anything in the docs that explains what's happening.

Add some more backslashes before the d, in C++ one needs 4, I'm not sure
if 2 are sufficient in python or not.


You love your home and want it to be beautiful.

More information about the PyQt mailing list