[PyKDE] about QPEApplication and QMainWindow

Michael Lauer mickey at tm.informatik.uni-frankfurt.de
Tue Sep 3 22:27:01 BST 2002


Hello,

> >
> > 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.
> 
> Ok, so have you any idea why my code does not receive the setDocument messages 
> ?
> 
> The main widget (the one passed to QPEApp::showMainDocumentWidget), is derived 
> from QMainWindow, with a defined setDocument function (which takes the doc 
> name as arg).
> For your info, this is an extract of the code in my (GPL) version of qtopia:
> _________________________________________________________
> qpeapplication.cpp:
> void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data)
> {
> ...
> ...
>     } else if ( msg == "setDocument(QString)" ) {
> 	d->keep_running = TRUE;
> 	QDataStream stream( data, IO_ReadOnly );
> 	QString doc;
> 	stream >> doc;
> 	QWidget *mw = mainWidget();
> 	if ( !mw )
> 	    mw = d->qpe_main_widget;
> 	if ( mw )
> 	    Global::setDocument( mw, doc );
>     } else if ( msg == "nextView()" ) {
> ...
> }
> 
> PS: global::setDocument is also called when starting the app, but it is in a 
> very similar way.
> _________________________________________________________
> global.cpp:
> void Global::setDocument( QWidget* receiver, const QString& document )
> {
>     Emitter emitter(receiver,document);
> }
> 
> class Emitter : public QObject {
>     Q_OBJECT
> public:
>     Emitter( QWidget* receiver, const QString& document )
>     {
> 	connect(this, SIGNAL(setDocument(const QString&)),
> 	    receiver, SLOT(setDocument(const QString&)));
> 	emit setDocument(document);
> 	disconnect(this, SIGNAL(setDocument(const QString&)),
> 	       receiver, SLOT(setDocument(const QString&)));
>     }
> 
> signals:
>     void setDocument(const QString&);
> };
> __________________________________________________________
> 
> Again, when I am using the standard above code, I do not receive any 
> "setDocument" message...
> 
> 
> I have also written an almost empty QPEMainWindow class (and it's PyQT 
> wrapper) like this :

Can you please publish the qpemainwindow.sip ?

> __________________________________________________________
> qpemainwindow.h:
> class QPEMainWindow : public QMainWindow
> {
>   Q_OBJECT
> 
> public:
>   QPEMainWindow( QWidget * parent = 0, const char * name = 0, WFlags f = 
> WType_TopLevel ) : QMainWindow(parent, name, f);
>   
> public slots:
>   virtual void setDocument(const QString &) {};
>   virtual void accept() {};
> 
> };
> ____________________________________________________________
> 
> When I use this code (my main widget is then a subclass of QPEMainWindow), I 
> DO receive all setDocument messages...
> This is why I suggested you to provide this class as a part of QtPy...
> 
> Have you any idea why this code works, while the with the original 
> QMainWindow, it does not work ?

Hmm.. I wonder if this could be somehow related to
the problem with widgets not receiving RightMouseButtonPressed,
where they should - because QPEApplication::setStylusOperation
(RightOnHold) has been called.

According to a patched libqpe.so the signal is emmited from c++
within a timer event, but it never reachs the PyQt widget instance...

Yours,

Mickey.


-- 
:M:
--------------------------------------------------------------------------
Dipl.-Inf. Michael 'Mickey' Lauer  
mickey at tm.informatik.uni-frankfurt.de 
  Raum 10b - ++49 69 798 28358       Fachbereich Informatik und Biologie
--------------------------------------------------------------------------




More information about the PyQt mailing list