from PySide.QtGui import QApplication, QDialog
from PySide.QtUiTools import QUiLoader

class MyQUiLoader(QUiLoader):
    def __init__(self):
        super(MyQUiLoader, self).__init__()

    def createWidget(self, *args):
        return super(MyQUiLoader, self).createWidget(*args)

def hello():
    print "Hello!"

qapp = QApplication([])

#ui = QUiLoader().load(u"test.ui")
ui = MyQUiLoader().load(u"test.ui")

# Using of MyQUiLoader leads to exception here:
ui.rejected.connect(hello)
# Traceback (most recent call last):                                                                                            
#  File "load_ui_test.py", line 20, in <module>
#    ui.rejected.connect(hello)
#RuntimeError: Internal C++ object (PySide.QtGui.QDialog) already deleted.

ui.show()

qapp.exec_()
