[PyKDE] connectSlotsByName do that really works in python?

Miguel Angel Cañedo mcanedo at grupogcm.com
Wed Dec 13 12:17:32 GMT 2006


I have been reading about the new auto connect  of Qt, I have been trying to 
get it workin with no success....
Is there a specific way or place to declare th functions?
What am i missiing?
Here is a very simple code from pyuic4 where I simply added a def:

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'uno.ui'
#
# Created: Wed Dec 13 06:08:19 2006
#      by: PyQt4 UI code generator 4-snapshot-20061203
#
# WARNING! All changes made in this file will be lost!

import sys
from PyQt4 import QtCore, QtGui

class Ui_Dialog(object):
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        
Dialog.resize(QtCore.QSize(QtCore.QRect(0,0,400,300).size()).expandedTo(Dialog.minimumSizeHint()))

        self.pushButton = QtGui.QPushButton(Dialog)
        self.pushButton.setGeometry(QtCore.QRect(290,250,80,27))
        self.pushButton.setObjectName("pushButton")

        self.retranslateUi(Dialog)
        QtCore.QMetaObject.connectSlotsByName(Dialog)

    def retranslateUi(self, Dialog):
        Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Dialog", 
None, QtGui.QApplication.UnicodeUTF8))
        
self.pushButton.setText(QtGui.QApplication.translate("Dialog", "PushButton", 
None, QtGui.QApplication.UnicodeUTF8))

    #######################
    def on_pushButton_clicked(self):
        print "whatever on console"
        self.close()
   #######################

if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    Dialog = QtGui.QDialog()
    ui = Ui_Dialog()
    ui.setupUi(Dialog)
    Dialog.show()




More information about the PyQt mailing list