def __init__(self, parent=None):
     QWidget.__init__(self, parent)
     self.setFixedSize(200, 120)
     quit = QPushButton('Quit', self)
     quit.setGeometry(62, 40, 75, 30);
     quit.setFont(QFont('Times', 18, QFont.Bold))
     quit.connect('clicked()', QApplication.instance().quit)
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        ui = loadUi('form.ui', self)
        print ui.objectName
        print
        children = ui.children()
        for child in children:
            print child, child.objectName

            #child.setParent(self)
            if isinstance(child, QWidget):
                print '    ', child.parentWidget()
                child.setParent(self)
            else:
                print '    ', type(child)
def create():
    window = QWidget()
    button1 = QPushButton("One")
    button2 = QPushButton("Two")
    button3 = QPushButton("Three")
    button4 = QPushButton("Four")
    button5 = QPushButton("Five")
    
    layout = QHBoxLayout()
    layout.addWidget(button1)
    layout.addWidget(button2)
    layout.addWidget(button3)
    layout.addWidget(button4)
    layout.addWidget(button5)
    
    window.setLayout(layout)
    window.show()
    return window
 def childEvent(self, e):
     print 'childEvent()', e
     #return QWidget.protected_childEvent(self, e)
     return QWidget.childEvent(self, e)
 def connectNotify(self, signal):
     print 'connectNotify()', self, signal
     QWidget.connectNotify(self, signal)
 def eventFilter(self, watched, event):
      print 'eventFilter()', watched, event
      return QWidget.eventFilter(self, watched, event)
# parent test

from Qt.Gui import QApplication, QPushButton, QWidget
app = QApplication()
form = QWidget()
okButton = QPushButton('Push me', form)
cancelButton = QPushButton('Push me', form)

okButton.show()
cancelButton.show()
form.show()

app.run()
from Qt.Gui import QApplication, QWidget, QPushButton, QHBoxLayout

app = QApplication()
window = QWidget()
button1 = QPushButton("One")
button2 = QPushButton("Two")
button3 = QPushButton("Three")
button4 = QPushButton("Four")
button5 = QPushButton("Five")

layout = QHBoxLayout()
layout.addWidget(button1)
layout.addWidget(button2)
layout.addWidget(button3)
layout.addWidget(button4)
layout.addWidget(button5)

window.setLayout(layout)
window.show()

app.run()
 def event(self, e):
     print e, e.type()
     return QWidget.event(self, e)
 def __init__(self, parent=None):
     QWidget.__init__(self, parent)
    
    def event(self, e):
        print e, e.type()
        return QWidget.event(self, e)

        
class MyButton(QPushButton):
    def __init__(self, text, parent=None):
        QPushButton.__init__(self, text, parent)
    
    def event(self, e):
        print e, e.type()
        return QPushButton.event(self, e)

                    
app = QApplication()
#button = QPushButton('Click me', None)
button = QWidget(None)
#button = MyButton('Click me', None)

#a = MyObject(None)
#b = MyObject(a)
# print a
# print b
# print b.parent()
# print a is b.parent()
#app.notify(b, QEvent(QEvent.Type.KeyPress))

button.show() 
app.run()
from sys import argv, exit
from Qt.Gui import QApplication, QWidget

app = QApplication()
w1 = QWidget(None)
w2 = QWidget(w1)
w1.show()
print dir(w1)
code = app.run()
exit(code)
from Qt.Gui import QApplication, QFont, QPushButton, QWidget

app = QApplication('t3')
window = QWidget()
window.resize(200, 120);
quit = QPushButton ('Quit', window)
quit.setFont(QFont('Times', 18, QFont.Bold))
quit.setGeometry(10, 40, 180, 40)
quit.connect('clicked()', app.quit)
window.show()
app.run()
 def mousePressEvent(self, e):
     print e, e.type()
     QWidget.mousePressEvent(self, e)
 def __init__(self, parent=None):
     QWidget.__init__(self, parent)
     self.setFixedSize(200, 120)
     quit = QPushButton('Quit', self)
     quit.setGeometry(62, 40, 75, 30);
     quit.connect('clicked(bool)', self.on_clicked)