[PyQt] qwidget launching problem

Enes Albay albayenes at gmail.com
Sun May 6 18:25:15 BST 2012


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?


---
Enes Albay


More information about the PyQt mailing list