[PyQt] bug in QTabWidget.indexOf() method?
dboddie at trolltech.com
Tue Sep 9 16:54:57 BST 2008
On Tue Sep 9 15:59:06 BST 2008, Scott Price wrote:
> 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...
This sounds like a mystery, but perhaps there's a simple explanation for it.
> So I put the indexOf() method inside a try...except: block, and the except
> block gets executed whenever the indexOf() fails.
Which exception is raised? Can you post a traceback?
> 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
It could be that there's a problem with self.spouseScroll itself. Perhaps the
object has been deleted. It's difficult to tell just by looking at these
lines of code. If you post more information about the traceback you get,
that might help.
More information about the PyQt