[PyKDE] qt.qApp, subclassing QApplication

Dan Sommers dan at tombstonezero.net
Sat Jan 17 18:33:00 GMT 2004


On Sat, 17 Jan 2004 17:09:47 +0000,
Phil Thompson <phil at riverbankcomputing.co.uk> wrote:

> > qApp does *not* refer to the instance of my subclass.
> 
> Sorry, I wasn't clear. They refer to the same C++ instance.

Aha.  Thanks for the clarification.

> > That is exactly the case:  that IWBNI the type of qApp were my
> > subclass rather than qApplication.  Perhaps this is a design
> > flaw, but I decided to add some application-wide utility
> > functions to my application subclass, mostly thin wrappers
> > around "emit( PYSIGNAL( 'somesignal' ), *args )" sorts of
> > utility functions.  That way, I can reference them from
> > anywhere as qApp.utilityfunction.
> 
> I think it's better to use a separate myApp global that you set
> in MyApp.__init__(). Otherwise you are just making your code
> more difficult to understand.

Yeah, you're right, a separate global (or two, or three...) is
probably cleaner; I'll do it that way instead.  I spent more than
twenty years creating *structured* programs, these newfangled
object oriented jobs still confuse me sometimes.  ;-)

Thank you for your replies.

Regards,
Dan

-- 
I hear, and I forget.                                  Dan Sommers
I see, and I remember.                 [insert your own joke here]
I do, and I understand.             <mailto:dan at tombstonezero.net>
            -- Confucius       <http://www.tombstonezero.net/dan/>




More information about the PyQt mailing list