[PyQt] bug in QTabWidget.indexOf() method?

Scott Price scottmprice at gmail.com
Tue Sep 9 15:59:06 BST 2008

So I have a tab widget, which when constructed gets a scroll area for
page/tab one.  Works fine.

During a later process I add another tab with a similar scroll area.
Works fine.

A separate process uses the indexOf() method to search for the second scroll
area that may not have been added yet.  When it finds nothing, the code
silently fails.  It doesn't crash, it just fails.  The function in which
this indexOf() method resides is exited without processing any of the
following code.  However, when the second scroll area _is_ found, all works
as expected...

So I put the indexOf() method inside a try...except: block, and the except
block gets executed whenever the indexOf() fails.  

Now, my understanding of the indexOf() method, according to the
documentation, is that it returns an int value, and -1 if the widget
searched for is not found.  So why does the code fail instead of returning

Here's the code line that fails:

	index = self.friendTab.indexOf(self.spouseScroll)
	self.goTo.setText('hhhh')  #a debug line, when the code fails, this
line is not executed

I'm a fairly novice programmer, so it's entirely possible I've made some
mistakes somewhere, however, I don't understand why this raises an
exception/fails instead of doing what the documentation says it should do,
which is return -1?

Thanks for taking a look,


More information about the PyQt mailing list