namespace problems in pyqt

Tom Chance tomchance at
Sun Mar 30 01:29:51 CET 2003


I've got a problem that's come about by not wanting to create a new 
class for a dialogue box in PyQt. Previously, I had a class for the dialogue
which included a function connected to a button in the dialogue. I made the
class for the dialogue box in Qt Designer, imported that class, inherited
it in a new class, into which I put the function (so it overrode the empty
function declaration in the original class), like so:

class Inherited(QDialog):
        /all the pyqt stuff/
        connect signal to function2

class Inheritor(Inherited):
        def function2:
                /so some stuff/ 

Now that function isn't in that dialogue's class... it's in the namespace
that is calling the class instance, e.g.:

def function1(self):
        /do some stuff.../
        instance = Inherited()

def function2(self):
        /do some stuff.../

How can I connect the button in Inherited to function2()? I've been told you
can connect a Qt signal to a global function, but I can't work out how;
I've tried declaring "global function2", and I've read through the Qt docs,
but I cant' figure it out, so I'm obviously just being dumb and missing
something here. Can someone give me a hand?


More information about the Python-list mailing list