[PyKDE] about QPEApplication and QMainWindow

Phil Thompson phil at river-bank.demon.co.uk
Sat Aug 17 13:25:01 BST 2002


David Douard wrote:

> Hi !
> 
> I am developping a little app (for the zaurus contest) using PyQt. And I have 
> found several problems...
> 
> First, I am still obliged to comment out a few lines in the sip files in order 
> to compile PyQt... (gcc complains about accessing vars which are declared 
> private in the master C++ class and thus not availbale in any derived 
> class---which is normal. So I still do not understand how PyQt can be 
> compiled out of the box. NB: I am using Qtopia as available to Trolltech's 
> site, GPL version).


Probably because I am using the SDK provided to the original contest 
entrants. I am not using the current GPL version - I will do when I get 
some spare time.


> Then I have spent almost a day to realize that I had many problems with the 
> Qtopia integration of my app which where du to the fact that the 
> /tmp/qcop-msg file was not opened, read end destroyed by my app... Which was 
> due to the fact that, in the QApplication code (file qapplication.cpp), the 
> name of the program (argv[0]) is filtered (to remove full path and so) AFTER 
> the file /tmp/qcop-msg/appname if opened... And Python gives the fullpath as 
> argv[0]...
> So I could solve this easily just by filtering the args given to my 
> QPEApplication constructor...
> 
> It's trivial but one can spen time on it (as I did). Maybe a little TIP file 
> (or FAQ entry) on the PyQt site would be nice ?
> 
> Last, I use a QMainWindow derived class as main widget. But the problem is 
> that the QMainApplication does NOT declare slots which are used by 
> QApplication to send messages like "newDocument" or "accept". In the C++ 
> world, you just have to subclass QMainApplication declaring thoses 
> fuctions... But if I subclass it with a python class, messages are not 
> transmited... I haven't looked deeply, but I  guess it is not possible for a 
> C++ class to send a message (at the c++ level. When I say send, I mean 
> calling the slot function as done in QPEApplication code for "setDocument", 
> for example) to a purely python defined slot... (Am I wrong ?)


Yes you are wrong. You can connect a C++ signal to any Python callable 
object (ie. a function or a method). If your Python slots are not being 
called then the problem is probably elsewhere.


> In this case you (I mean Phil) should provide a QPEMainApplication class with 
> an associated  python  binding which just declare thoses required slot 
> functions as virtual, so user can redefine them at Python level. 
> It is what I have done for my little app, but it would be nice to have that 
> explained and implemented in PyQt...


This isn't necessary.

Phil




More information about the PyQt mailing list