PyQt... What am I doing wrong?!
Hi guys, just starting out with Qt using PyQt, and not having a great time! Anyone help me out here... I'm trying to get a button to print "hello world". Stereotypical and unimaginative, I know, but hey, you have to start somewhere! Problem is, I click it and nothing happens! It's not even calling the function. I think my connect statement is rubbish. Can you help?
Ta,
Rich
from PyQt4 import QtCore, QtGui
Code:
class Ui_About(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(388, 336)
self.
btnOK.
setGeometry(QtCore.
QRect(130,
300,
110,
23)) self.btnOK.setObjectName("btnOK")
QtCore.
QObject.
connect(self.
btnOK, QtCore.
SIGNAL("clicked()"), self.
hello)
def hello(self):
print "hello world"
Re: PyQt... What am I doing wrong?!
Ui_about is not a QObject, it can't have slots. If you modified the code generated by pyuic then don't do it. You should provide your own subclass of QWidget and place the slot there. Consult the docs for using Designer generated components in your application.
Re: PyQt... What am I doing wrong?!
Much appreciated, got it all working now, many thanks.