[PyKDE] about DCOP, QDataStream, <<, and >>

Phil Thompson phil at river-bank.demon.co.uk
Sun Dec 1 00:38:00 GMT 2002


On Saturday 30 November 2002 7:23 pm, Jim Bublitz wrote:
> On 30-Nov-02 Jim Bublitz wrote:
> > On 30-Nov-02 Me wrote:
> >> Hi, I'm trying to figure out how to use the DCOP interface. The
> >> KDE C++
> >> examples make use of << and >>, but how to do it with python? Is
> >> there a work
> >> around for this?
> >>
> >> The example I'm working from has a part like so:
> >>
> >> void MainWindow::bookLocation()
> >> {
> >>     DCOPClient *client=kapp->dcopClient();
> >>     QByteArray params;
> >>     QDataStream stream(params, IO_WriteOnly);
> >>     stream << location->text();
> >>     if (!client->send("p6-*", "bookmarkList", "add(QString)",
> >> params))
> >>        kdDebug() << "Error with DCOP\n";
> >> }
> >>
> >> How would I do that with python? Thanks for any help.
> >
> > The short, quick, and unsatisfying answer is "I don't know". I've
> > been aware that the DCOP interface in PyKDE *might* be
> > incomplete, but haven't looked much farther than that. I seem to
> > recall that I did see a way around this, but I'm not sure what
> > it might be at the moment. I'll look into it and try to have an
> > answer in the next day or two. Please post again if I don't get
> > you an answer in that timeframe.
>
> It looks like you should be able to use QDataStream.writeBytes
> or QDataStream.writeRawBytes to put data on the stream. These
> are declared in qdatastream.sip as:
>
> QDataStream &writeBytes(const char * /Array/,uint /ArraySize/);
> QDataStream &writeRawBytes(const char * /Array/,uint /ArraySize/);
>
> I'm assuming the /.../ stuff (Phil ??) means that from Python you
> only need to supply the char string and sip will compute the length
> and pass it to Qt for you, eg:
>
>     stream.writeBytes (location.text())

Correct.

Phil




More information about the PyQt mailing list