[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] qwidget launching problem
From:       Enes Albay <albayenes () gmail ! com>
Date:       2012-05-06 19:58:20
Message-ID: 4FA6D7DC.4050407 () gmail ! com
[Download RAW message or body]


On 05/06/2012 08:55 PM, Phil Thompson wrote:
>  On Sun, 06 May 2012 20:25:15 +0300, Enes Albay<albayenes@gmail.com>
>  wrote:
>>  Hi,
>>
>>
>>  If i implement my class like below:
>>
>>  class MainWindow(QtGui.QMainWindow):
>>        def __init__(self):
>>            super(MainWindow, self).__init__()
>>            self.initUI()
>>
>>        def initUI():
>>            ....
>>            ....
>>            self.showButton = QtGui.QPushButton(u"KlavyeyiGoster",
>>  self.mainWidget)
>>            self.showButton.resize(self.showButton.sizeHint())
>>            self.showButton.clicked.connect(self.widgetClicked)
>>            ....
>>            ....
>>
>>
>>        def widgetClicked(self):
>>            self.newWidget = QtGui.QWidget();
>>            self.newWidget.setGeometry(0, 0, 300, 300)
>>            self.newWidget.show()
>>
>>  when i click Button, newWidget is constructed and showed. But if i
>>  change "widgetClicked" method like this:
>>
>>  def widgetClicked(self):
>>            newWidget = QtGui.QWidget();
>>            newWidget.setGeometry(0, 0, 300, 300)
>>            newWidget.show()
>>
>>  when i clicked the button, it doesn't show anything. There are no
>>  compilation or run time errors.
>>
>>  What is the reason of this difference?
>  In the second version you aren't keeping a reference to the widget (either
>  explicitly or implicitly by giving it a parent) so it is getting garbage
>  collected when widgetClicked() returns.
>
>  Phil
Thanks for your quick replies, Phil and Detlev :)

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic