Hi All,
Given the recent segfault discussion, I have attached an example piece of code
which segfaults. I am not sure if this is a bug, or just my own stupidity
though. According to the PyQT book, the way to remove a widget from it's
parent is to do the following:
myParent.removeChild(myChild)
del myChild
The PyQT/Sip bindings seems to break if these commands gets triggered by a
signal from within a child widget of the widget that is to be removed.
I get a segfault when I do the following:
1. Run the program (testdel.py)
2. Click on the DelButton button.
3. Switch to another application using Alt-Tab
4. Switch back to my testdel app.
This happens under RH9.0. (Python-2.2.2-26, PyQt-3.5-5, qt-3.1.1-6) I use the
KDE desktop environment.
Does anyone know if this is a bug or how to fix/workaround this?
TIA,
Kind regards,
Henry
--
Henry Kleynhans <[EMAIL PROTECTED]>
Obsidian Systems#!/usr/bin/python
#
#
import sys
from qt import *
class TestWidget(QWidget):
def __init__(self, *args):
apply(QWidget.__init__, (self,) + args)
self.button = QPushButton("DelButton", self)
self.button.resize(self.button.sizeHint())
QObject.connect(self.button, SIGNAL("clicked()"),
self.slotClicked)
pass
def slotClicked(self):
self.emit(PYSIGNAL("sigKillButton"), ())
pass
class MainWindow(QMainWindow):
def __init__(self, *args):
apply(QMainWindow.__init__, (self,) + args)
self.widget = TestWidget(self)
self.connect(self.widget, PYSIGNAL("sigKillButton"),
self.removeButton)
pass
def removeButton(self):
self.removeChild(self.widget)
del self.widget
self.addButton = QPushButton("Added Button", self)
self.addButton.resize(self.addButton.sizeHint())
self.addButton.show()
pass
pass # MainWindow
def main(args):
app = QApplication(args)
win = MainWindow()
win.show()
app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
app.exec_loop()
pass
if __name__ == "__main__":
main(sys.argv)
pass