[PyKDE] Segmentation fault with QTabBar/QTab

Kaercher, Joerg JKaercher at bruker-axs.com
Tue Jun 11 00:23:01 BST 2002


Hi,

I am trying to use the QTabBar/QTab classes and get a segmentation fault
when a tab is removed from the bar. I found a message in the PyKDE archive
that mentions that on the C++ level QTabBar::removeTab() calls the
destructor for the QTab object. Is it possible that the garbage collector in
Python tries to do the same and thereby causes the segementation fault? Any
ideas? (I am using PyQt 3.2.4 and Qt 3.0.4 under Linux)

Thanks.

Joerg



Here is a short sample program that demonstrates the problem. The second
setNumTabs() call crashes the program.

import qt
import sys
 
class TabBar(qt.QTabBar):
    def clear(self):
        for n in range(self.count()):
            self.removeTab(self.tab(n))
    def setNumTabs(self,num):
        self.clear()
        for n in range(num):
            self.insertTab(qt.QTab('%d'%(n+1)),n)
 
a=qt.QApplication(sys.argv)
 
w=TabBar()
w.setNumTabs(5)
w.setNumTabs(7)
 
a.setMainWidget(w)
w.show()
a.exec_loop()




More information about the PyQt mailing list